本文整理汇总了PHP中DatabaseBase::replaceVars方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseBase::replaceVars方法的具体用法?PHP DatabaseBase::replaceVars怎么用?PHP DatabaseBase::replaceVars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseBase
的用法示例。
在下文中一共展示了DatabaseBase::replaceVars方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replaceVars
/**
* Postgres specific version of replaceVars.
* Calls the parent version in Database.php
*
* @private
*
* @param $ins String: SQL string, read from a stream (usually tables.sql)
*
* @return string SQL string
*/
protected function replaceVars($ins)
{
$ins = parent::replaceVars($ins);
if ($this->numeric_version >= 8.300000000000001) {
// Thanks for not providing backwards-compatibility, 8.3
$ins = preg_replace("/to_tsvector\\s*\\(\\s*'default'\\s*,/", 'to_tsvector(', $ins);
}
if ($this->numeric_version <= 8.1) {
// Our minimum version
$ins = str_replace('USING gin', 'USING gist', $ins);
}
return $ins;
}
示例2: replaceVars
/**
* @param $s string
* @return string
*/
protected function replaceVars($s)
{
$s = parent::replaceVars($s);
if (preg_match('/^\\s*(CREATE|ALTER) TABLE/i', $s)) {
// CREATE TABLE hacks to allow schema file sharing with MySQL
// binary/varbinary column type -> blob
$s = preg_replace('/\\b(var)?binary(\\(\\d+\\))/i', 'BLOB', $s);
// no such thing as unsigned
$s = preg_replace('/\\b(un)?signed\\b/i', '', $s);
// INT -> INTEGER
$s = preg_replace('/\\b(tiny|small|medium|big|)int(\\s*\\(\\s*\\d+\\s*\\)|\\b)/i', 'INTEGER', $s);
// floating point types -> REAL
$s = preg_replace('/\\b(float|double(\\s+precision)?)(\\s*\\(\\s*\\d+\\s*(,\\s*\\d+\\s*)?\\)|\\b)/i', 'REAL', $s);
// varchar -> TEXT
$s = preg_replace('/\\b(var)?char\\s*\\(.*?\\)/i', 'TEXT', $s);
// TEXT normalization
$s = preg_replace('/\\b(tiny|medium|long)text\\b/i', 'TEXT', $s);
// BLOB normalization
$s = preg_replace('/\\b(tiny|small|medium|long|)blob\\b/i', 'BLOB', $s);
// BOOL -> INTEGER
$s = preg_replace('/\\bbool(ean)?\\b/i', 'INTEGER', $s);
// DATETIME -> TEXT
$s = preg_replace('/\\b(datetime|timestamp)\\b/i', 'TEXT', $s);
// No ENUM type
$s = preg_replace('/\\benum\\s*\\([^)]*\\)/i', 'TEXT', $s);
// binary collation type -> nothing
$s = preg_replace('/\\bbinary\\b/i', '', $s);
// auto_increment -> autoincrement
$s = preg_replace('/\\bauto_increment\\b/i', 'AUTOINCREMENT', $s);
// No explicit options
$s = preg_replace('/\\)[^);]*(;?)\\s*$/', ')\\1', $s);
// AUTOINCREMENT should immedidately follow PRIMARY KEY
$s = preg_replace('/primary key (.*?) autoincrement/i', 'PRIMARY KEY AUTOINCREMENT $1', $s);
} elseif (preg_match('/^\\s*CREATE (\\s*(?:UNIQUE|FULLTEXT)\\s+)?INDEX/i', $s)) {
// No truncated indexes
$s = preg_replace('/\\(\\d+\\)/', '', $s);
// No FULLTEXT
$s = preg_replace('/\\bfulltext\\b/i', '', $s);
}
return $s;
}
示例3: replaceVars
public function replaceVars($ins)
{
$varnames = array('wgDBprefix');
if ($this->mFlags & DBO_SYSDBA) {
$varnames[] = 'wgDBOracleDefTS';
$varnames[] = 'wgDBOracleTempTS';
}
// Ordinary variables
foreach ($varnames as $var) {
if (isset($GLOBALS[$var])) {
$val = addslashes($GLOBALS[$var]);
// FIXME: safety check?
$ins = str_replace('{$' . $var . '}', $val, $ins);
$ins = str_replace('/*$' . $var . '*/`', '`' . $val, $ins);
$ins = str_replace('/*$' . $var . '*/', $val, $ins);
}
}
return parent::replaceVars($ins);
}