本文整理汇总了PHP中PDO::sqliteCreateCollation方法的典型用法代码示例。如果您正苦于以下问题:PHP PDO::sqliteCreateCollation方法的具体用法?PHP PDO::sqliteCreateCollation怎么用?PHP PDO::sqliteCreateCollation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PDO
的用法示例。
在下文中一共展示了PDO::sqliteCreateCollation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: open
/**
* {@inheritdoc}
*/
public static function open(array &$connection_options = array())
{
// Allow PDO options to be overridden.
$connection_options += array('pdo' => array());
$connection_options['pdo'] += array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, \PDO::ATTR_STRINGIFY_FETCHES => TRUE);
$pdo = new \PDO('sqlite:' . $connection_options['database'], '', '', $connection_options['pdo']);
// Create functions needed by SQLite.
$pdo->sqliteCreateFunction('if', array(__CLASS__, 'sqlFunctionIf'));
$pdo->sqliteCreateFunction('greatest', array(__CLASS__, 'sqlFunctionGreatest'));
$pdo->sqliteCreateFunction('pow', 'pow', 2);
$pdo->sqliteCreateFunction('exp', 'exp', 1);
$pdo->sqliteCreateFunction('length', 'strlen', 1);
$pdo->sqliteCreateFunction('md5', 'md5', 1);
$pdo->sqliteCreateFunction('concat', array(__CLASS__, 'sqlFunctionConcat'));
$pdo->sqliteCreateFunction('concat_ws', array(__CLASS__, 'sqlFunctionConcatWs'));
$pdo->sqliteCreateFunction('substring', array(__CLASS__, 'sqlFunctionSubstring'), 3);
$pdo->sqliteCreateFunction('substring_index', array(__CLASS__, 'sqlFunctionSubstringIndex'), 3);
$pdo->sqliteCreateFunction('rand', array(__CLASS__, 'sqlFunctionRand'));
$pdo->sqliteCreateFunction('regexp', array(__CLASS__, 'sqlFunctionRegexp'));
// SQLite does not support the LIKE BINARY operator, so we overload the
// non-standard GLOB operator for case-sensitive matching. Another option
// would have been to override another non-standard operator, MATCH, but
// that does not support the NOT keyword prefix.
$pdo->sqliteCreateFunction('glob', array(__CLASS__, 'sqlFunctionLikeBinary'));
// Create a user-space case-insensitive collation with UTF-8 support.
$pdo->sqliteCreateCollation('NOCASE_UTF8', array('Drupal\\Component\\Utility\\Unicode', 'strcasecmp'));
// Execute sqlite init_commands.
if (isset($connection_options['init_commands'])) {
$pdo->exec(implode('; ', $connection_options['init_commands']));
}
return $pdo;
}
示例2: open
/**
* {@inheritdoc}
*/
public static function open(array &$connection_options = array())
{
// Allow PDO options to be overridden.
$connection_options += array('pdo' => array());
$connection_options['pdo'] += array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, \PDO::ATTR_STRINGIFY_FETCHES => TRUE);
$pdo = new \PDO('sqlite:' . $connection_options['database'], '', '', $connection_options['pdo']);
// Create functions needed by SQLite.
$pdo->sqliteCreateFunction('if', array(__CLASS__, 'sqlFunctionIf'));
$pdo->sqliteCreateFunction('greatest', array(__CLASS__, 'sqlFunctionGreatest'));
$pdo->sqliteCreateFunction('pow', 'pow', 2);
$pdo->sqliteCreateFunction('exp', 'exp', 1);
$pdo->sqliteCreateFunction('length', 'strlen', 1);
$pdo->sqliteCreateFunction('md5', 'md5', 1);
$pdo->sqliteCreateFunction('concat', array(__CLASS__, 'sqlFunctionConcat'));
$pdo->sqliteCreateFunction('concat_ws', array(__CLASS__, 'sqlFunctionConcatWs'));
$pdo->sqliteCreateFunction('substring', array(__CLASS__, 'sqlFunctionSubstring'), 3);
$pdo->sqliteCreateFunction('substring_index', array(__CLASS__, 'sqlFunctionSubstringIndex'), 3);
$pdo->sqliteCreateFunction('rand', array(__CLASS__, 'sqlFunctionRand'));
$pdo->sqliteCreateFunction('regexp', array(__CLASS__, 'sqlFunctionRegexp'));
// Create a user-space case-insensitive collation with UTF-8 support.
$pdo->sqliteCreateCollation('NOCASE_UTF8', array('Drupal\\Component\\Utility\\Unicode', 'strcasecmp'));
// Execute sqlite init_commands.
if (isset($connection_options['init_commands'])) {
$pdo->exec(implode('; ', $connection_options['init_commands']));
}
return $pdo;
}