*
* @return bool|null previous value of the flag
*/
- function debug( $debug = null ) {
+ public function debug( $debug = null ) {
return wfSetBit( $this->mFlags, DBO_DEBUG, $debug );
}
*
* @return null|bool The previous value of the flag
*/
- function bufferResults( $buffer = null ) {
+ public function bufferResults( $buffer = null ) {
if ( is_null( $buffer ) ) {
return !(bool)( $this->mFlags & DBO_NOBUFFER );
} else {
*
* @return bool The previous value of the flag.
*/
- function ignoreErrors( $ignoreErrors = null ) {
+ public function ignoreErrors( $ignoreErrors = null ) {
return wfSetBit( $this->mFlags, DBO_IGNORE, $ignoreErrors );
}
* @param $level int An integer (0 or 1), or omitted to leave it unchanged.
* @return int The previous value
*/
- function trxLevel( $level = null ) {
+ public function trxLevel( $level = null ) {
return wfSetVar( $this->mTrxLevel, $level );
}
* @param $count int The count to set, or omitted to leave it unchanged.
* @return int The error count
*/
- function errorCount( $count = null ) {
+ public function errorCount( $count = null ) {
return wfSetVar( $this->mErrorCount, $count );
}
* @param $prefix string The table prefix to set, or omitted to leave it unchanged.
* @return string The previous table prefix.
*/
- function tablePrefix( $prefix = null ) {
+ public function tablePrefix( $prefix = null ) {
return wfSetVar( $this->mTablePrefix, $prefix );
}
*
* @return LoadBalancer|null
*/
- function getLBInfo( $name = null ) {
+ public function getLBInfo( $name = null ) {
if ( is_null( $name ) ) {
return $this->mLBInfo;
} else {
* @param $name
* @param $value
*/
- function setLBInfo( $name, $value = null ) {
+ public function setLBInfo( $name, $value = null ) {
if ( is_null( $value ) ) {
$this->mLBInfo = $name;
} else {
*
* @param $lag int
*/
- function setFakeSlaveLag( $lag ) {
+ public function setFakeSlaveLag( $lag ) {
$this->mFakeSlaveLag = $lag;
}
*
* @param $enabled bool
*/
- function setFakeMaster( $enabled = true ) {
+ public function setFakeMaster( $enabled = true ) {
$this->mFakeMaster = $enabled;
}
*
* @return bool
*/
- function cascadingDeletes() {
+ public function cascadingDeletes() {
return false;
}
*
* @return bool
*/
- function cleanupTriggers() {
+ public function cleanupTriggers() {
return false;
}
*
* @return bool
*/
- function strictIPs() {
+ public function strictIPs() {
return false;
}
*
* @return bool
*/
- function realTimestamps() {
+ public function realTimestamps() {
return false;
}
*
* @return bool
*/
- function implicitGroupby() {
+ public function implicitGroupby() {
return true;
}
*
* @return bool
*/
- function implicitOrderby() {
- return true;
- }
-
- /**
- * Returns true if this database requires that SELECT DISTINCT queries require that all
- ORDER BY expressions occur in the SELECT list per the SQL92 standard
- *
- * @return bool
- */
- function standardSelectDistinct() {
+ public function implicitOrderby() {
return true;
}
*
* @return bool
*/
- function searchableIPs() {
+ public function searchableIPs() {
return false;
}
*
* @return bool
*/
- function functionalIndexes() {
+ public function functionalIndexes() {
return false;
}
* Return the last query that went through DatabaseBase::query()
* @return String
*/
- function lastQuery() {
+ public function lastQuery() {
return $this->mLastQuery;
}
*
* @return bool
*/
- function doneWrites() {
+ public function doneWrites() {
return $this->mDoneWrites;
}
* Is a connection to the database open?
* @return Boolean
*/
- function isOpen() {
+ public function isOpen() {
return $this->mOpened;
}
* and removes it in command line mode
* - DBO_PERSISTENT: use persistant database connection
*/
- function setFlag( $flag ) {
+ public function setFlag( $flag ) {
global $wgDebugDBTransactions;
$this->mFlags |= $flag;
if ( ( $flag & DBO_TRX) & $wgDebugDBTransactions ) {
*
* @param $flag: same as setFlag()'s $flag param
*/
- function clearFlag( $flag ) {
+ public function clearFlag( $flag ) {
global $wgDebugDBTransactions;
$this->mFlags &= ~$flag;
if ( ( $flag & DBO_TRX ) && $wgDebugDBTransactions ) {
* @param $flag: same as setFlag()'s $flag param
* @return Boolean
*/
- function getFlag( $flag ) {
+ public function getFlag( $flag ) {
return !!( $this->mFlags & $flag );
}
*
* @return string
*/
- function getProperty( $name ) {
+ public function getProperty( $name ) {
return $this->$name;
}
/**
* @return string
*/
- function getWikiID() {
+ public function getWikiID() {
if ( $this->mTablePrefix ) {
return "{$this->mDBname}-{$this->mTablePrefix}";
} else {
throw new MWException( 'Database serialization may cause problems, since the connection is not restored on wakeup.' );
}
- /**
- * Same as new DatabaseMysql( ... ), kept for backward compatibility
- * @deprecated since 1.17
- *
- * @param $server
- * @param $user
- * @param $password
- * @param $dbName
- * @param $flags int
- * @return DatabaseMysql
- */
- static function newFromParams( $server, $user, $password, $dbName, $flags = 0 ) {
- wfDeprecated( __METHOD__, '1.17' );
- return new DatabaseMysql( $server, $user, $password, $dbName, $flags );
- }
-
- /**
- * Same as new factory( ... ), kept for backward compatibility
- * @deprecated since 1.18
- * @see Database::factory()
- * @return DatabaseBase
- */
- public final static function newFromType( $dbType, $p = array() ) {
- wfDeprecated( __METHOD__, '1.18' );
- if ( isset( $p['tableprefix'] ) ) {
- $p['tablePrefix'] = $p['tableprefix'];
- }
- return self::factory( $dbType, $p );
- }
-
/**
* Given a DB type, construct the name of the appropriate child class of
* DatabaseBase. This is designed to replace all of the manual stuff like:
*
* @return bool
*/
- function isWriteQuery( $sql ) {
+ public function isWriteQuery( $sql ) {
return !preg_match( '/^(?:SELECT|BEGIN|ROLLBACK|COMMIT|SET|SHOW|EXPLAIN|\(SELECT)\b/i', $sql );
}
* @param $fname String
* @param $tempIgnore Boolean
*/
- function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) {
+ public function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) {
# Ignore errors during error handling to avoid infinite recursion
$ignore = $this->ignoreErrors( true );
++$this->mErrorCount;
* & = filename; reads the file and inserts as a blob
* (we don't use this though...)
*
- * This function should not be used directly by new code outside of the
- * database classes. The query wrapper functions (select() etc.) should be
- * used instead.
- *
* @param $sql string
* @param $func string
*
* @return array
*/
- function prepare( $sql, $func = 'DatabaseBase::prepare' ) {
+ protected function prepare( $sql, $func = 'DatabaseBase::prepare' ) {
/* MySQL doesn't support prepared statements (yet), so just
pack up the query for reference. We'll manually replace
the bits later. */
* Free a prepared query, generated by prepare().
* @param $prepared
*/
- function freePrepared( $prepared ) {
+ protected function freePrepared( $prepared ) {
/* No-op by default */
}
*
* @return ResultWrapper
*/
- function execute( $prepared, $args = null ) {
+ public function execute( $prepared, $args = null ) {
if ( !is_array( $args ) ) {
# Pull the var args
$args = func_get_args();
}
/**
- * Prepare & execute an SQL statement, quoting and inserting arguments
- * in the appropriate places.
+ * For faking prepared SQL statements on DBs that don't support it directly.
*
- * This function should not be used directly by new code outside of the
- * database classes. The query wrapper functions (select() etc.) should be
- * used instead.
- *
- * @param $query String
- * @param $args ...
- *
- * @return ResultWrapper
- */
- function safeQuery( $query, $args = null ) {
- $prepared = $this->prepare( $query, 'DatabaseBase::safeQuery' );
-
- if ( !is_array( $args ) ) {
- # Pull the var args
- $args = func_get_args();
- array_shift( $args );
- }
-
- $retval = $this->execute( $prepared, $args );
- $this->freePrepared( $prepared );
-
- return $retval;
- }
-
- /**
- * For faking prepared SQL statements on DBs that don't support
- * it directly.
* @param $preparedQuery String: a 'preparable' SQL statement
* @param $args Array of arguments to fill it with
* @return string executable SQL
*/
- function fillPrepared( $preparedQuery, $args ) {
+ public function fillPrepared( $preparedQuery, $args ) {
reset( $args );
$this->preparedArgs =& $args;
* @param $matches Array
* @return String
*/
- function fillPreparedArg( $matches ) {
+ protected function fillPreparedArg( $matches ) {
switch( $matches[1] ) {
case '\\?': return '?';
case '\\!': return '!';
*
* @param $res Mixed: A SQL result
*/
- function freeResult( $res ) {
- }
-
- /**
- * Simple UPDATE wrapper.
- * Usually throws a DBQueryError on failure.
- * If errors are explicitly ignored, returns success
- *
- * This function exists for historical reasons, DatabaseBase::update() has a more standard
- * calling convention and feature set
- *
- * @param $table string
- * @param $var
- * @param $value
- * @param $cond
- * @param $fname string
- *
- * @return bool
- */
- function set( $table, $var, $value, $cond, $fname = 'DatabaseBase::set' ) {
- $table = $this->tableName( $table );
- $sql = "UPDATE $table SET $var = '" .
- $this->strencode( $value ) . "' WHERE ($cond)";
-
- return (bool)$this->query( $sql, $fname );
- }
+ public function freeResult( $res ) {}
/**
* A SELECT wrapper which returns a single field from a single result row.
*
* @return bool|mixed The value from the field, or false on failure.
*/
- function selectField( $table, $var, $cond = '', $fname = 'DatabaseBase::selectField',
+ public function selectField( $table, $var, $cond = '', $fname = 'DatabaseBase::selectField',
$options = array() )
{
if ( !is_array( $options ) ) {
* @return Array
* @see DatabaseBase::select()
*/
- function makeSelectOptions( $options ) {
+ public function makeSelectOptions( $options ) {
$preLimitTail = $postLimitTail = '';
$startOpts = '';
* @param $vars string|array
*
* May be either a field name or an array of field names. The field names
- * here are complete fragments of SQL, for direct inclusion into the SELECT
- * query. Expressions and aliases may be specified as in SQL, for example:
+ * can be complete fragments of SQL, for direct inclusion into the SELECT
+ * query. If an array is given, field aliases can be specified, for example:
+ *
+ * array( 'maxrev' => 'MAX(rev_id)' )
*
- * array( 'MAX(rev_id) AS maxrev' )
+ * This includes an expression with the alias "maxrev" in the query.
*
* If an expression is given, care must be taken to ensure that it is
* DBMS-independent.
* DBQueryError exception will be thrown, except if the "ignore errors"
* option was set, in which case false will be returned.
*/
- function select( $table, $vars, $conds = '', $fname = 'DatabaseBase::select',
+ public function select( $table, $vars, $conds = '', $fname = 'DatabaseBase::select',
$options = array(), $join_conds = array() ) {
$sql = $this->selectSQLText( $table, $vars, $conds, $fname, $options, $join_conds );
/**
* The equivalent of DatabaseBase::select() except that the constructed SQL
- * is returned, instead of being immediately executed.
+ * is returned, instead of being immediately executed. This can be useful for
+ * doing UNION queries, where the SQL text of each query is needed. In general,
+ * however, callers outside of Database classes should just use select().
*
* @param $table string|array Table name
* @param $vars string|array Field names
* @return string SQL query string.
* @see DatabaseBase::select()
*/
- function selectSQLText( $table, $vars, $conds = '', $fname = 'DatabaseBase::select', $options = array(), $join_conds = array() ) {
+ public function selectSQLText( $table, $vars, $conds = '', $fname = 'DatabaseBase::select',
+ $options = array(), $join_conds = array() )
+ {
if ( is_array( $vars ) ) {
- $vars = implode( ',', $vars );
+ $vars = implode( ',', $this->fieldNamesWithAlias( $vars ) );
}
$options = (array)$options;
*
* @return object|bool
*/
- function selectRow( $table, $vars, $conds, $fname = 'DatabaseBase::selectRow',
+ public function selectRow( $table, $vars, $conds, $fname = 'DatabaseBase::selectRow',
$options = array(), $join_conds = array() )
{
$options = (array)$options;
$fname = 'DatabaseBase::estimateRowCount', $options = array() )
{
$rows = 0;
- $res = $this->select ( $table, 'COUNT(*) AS rowcount', $conds, $fname, $options );
+ $res = $this->select( $table, array( 'rowcount' => 'COUNT(*)' ), $conds, $fname, $options );
if ( $res ) {
$row = $this->fetchRow( $res );
* @param $fname String: calling function name (optional)
* @return Boolean: whether $table has filed $field
*/
- function fieldExists( $table, $field, $fname = 'DatabaseBase::fieldExists' ) {
+ public function fieldExists( $table, $field, $fname = 'DatabaseBase::fieldExists' ) {
$info = $this->fieldInfo( $table, $field );
return (bool)$info;
*
* @return bool|null
*/
- function indexExists( $table, $index, $fname = 'DatabaseBase::indexExists' ) {
+ public function indexExists( $table, $index, $fname = 'DatabaseBase::indexExists' ) {
$info = $this->indexInfo( $table, $index, $fname );
if ( is_null( $info ) ) {
return null;
*
* @return bool
*/
- function tableExists( $table, $fname = __METHOD__ ) {
+ public function tableExists( $table, $fname = __METHOD__ ) {
$table = $this->tableName( $table );
$old = $this->ignoreErrors( true );
$res = $this->query( "SELECT 1 FROM $table LIMIT 1", $fname );
* @param $index
* @return string
*/
- function fieldType( $res, $index ) {
+ public function fieldType( $res, $index ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
}
*
* @return bool
*/
- function indexUnique( $table, $index ) {
+ public function indexUnique( $table, $index ) {
$indexInfo = $this->indexInfo( $table, $index );
if ( !$indexInfo ) {
* @param $options array
* @return string
*/
- function makeInsertOptions( $options ) {
+ protected function makeInsertOptions( $options ) {
return implode( ' ', $options );
}
*
* @return bool
*/
- function insert( $table, $a, $fname = 'DatabaseBase::insert', $options = array() ) {
+ public function insert( $table, $a, $fname = 'DatabaseBase::insert', $options = array() ) {
# No rows to insert, easy just return now
if ( !count( $a ) ) {
return true;
* @param $options Array: The options passed to DatabaseBase::update
* @return string
*/
- function makeUpdateOptions( $options ) {
+ protected function makeUpdateOptions( $options ) {
if ( !is_array( $options ) ) {
$options = array( $options );
}
*
* @return string
*/
- function makeList( $a, $mode = LIST_COMMA ) {
+ public function makeList( $a, $mode = LIST_COMMA ) {
if ( !is_array( $a ) ) {
throw new DBUnexpectedError( $this, 'DatabaseBase::makeList called with incorrect parameters' );
}
* The keys on each level may be either integers or strings.
*
* @param $data Array: organized as 2-d
- * array(baseKeyVal => array(subKeyVal => <ignored>, ...), ...)
+ * array(baseKeyVal => array(subKeyVal => [ignored], ...), ...)
* @param $baseKey String: field name to match the base-level keys to (eg 'pl_namespace')
* @param $subKey String: field name to match the sub-level keys to (eg 'pl_title')
* @return Mixed: string SQL fragment, or false if no items in array.
*/
- function makeWhereFrom2d( $data, $baseKey, $subKey ) {
+ public function makeWhereFrom2d( $data, $baseKey, $subKey ) {
$conds = array();
foreach ( $data as $base => $sub ) {
}
/**
- * Bitwise operations
+ * Return aggregated value alias
+ *
+ * @param $valuedata
+ * @param $valuename string
+ *
+ * @return string
*/
+ public function aggregateValue( $valuedata, $valuename = 'value' ) {
+ return $valuename;
+ }
/**
* @param $field
* @return string
*/
- function bitNot( $field ) {
+ public function bitNot( $field ) {
return "(~$field)";
}
* @param $fieldRight
* @return string
*/
- function bitAnd( $fieldLeft, $fieldRight ) {
+ public function bitAnd( $fieldLeft, $fieldRight ) {
return "($fieldLeft & $fieldRight)";
}
* @param $fieldRight
* @return string
*/
- function bitOr( $fieldLeft, $fieldRight ) {
+ public function bitOr( $fieldLeft, $fieldRight ) {
return "($fieldLeft | $fieldRight)";
}
+ /**
+ * Build a concatenation list to feed into a SQL query
+ * @param $stringList Array: list of raw SQL expressions; caller is responsible for any quoting
+ * @return String
+ */
+ public function buildConcat( $stringList ) {
+ return 'CONCAT(' . implode( ',', $stringList ) . ')';
+ }
+
/**
* Change the current database
*
*
* @return bool Success or failure
*/
- function selectDB( $db ) {
+ public function selectDB( $db ) {
# Stub. Shouldn't cause serious problems if it's not overridden, but
# if your database engine supports a concept similar to MySQL's
# databases you may as well.
/**
* Get the current DB name
*/
- function getDBname() {
+ public function getDBname() {
return $this->mDBname;
}
/**
* Get the server hostname or IP address
*/
- function getServer() {
+ public function getServer() {
return $this->mServer;
}
* raw - Do not add identifier quotes to the table name
* @return String: full database name
*/
- function tableName( $name, $format = 'quoted' ) {
+ public function tableName( $name, $format = 'quoted' ) {
global $wgSharedDB, $wgSharedPrefix, $wgSharedTables;
# Skip the entire process when we have a string quoted on both ends.
# Note that we check the end so that we will still quote any use of
# Quote the $database and $table and apply the prefix if not quoted.
if ( isset( $database ) ) {
- $database = ( $format == 'quoted' || $this->isQuotedIdentifier( $database ) ? $database : $this->addIdentifierQuotes( $database ) );
+ if ( $format == 'quoted' && !$this->isQuotedIdentifier( $database ) ) {
+ $database = $this->addIdentifierQuotes( $database );
+ }
}
$table = "{$prefix}{$table}";
return $retval;
}
+ /**
+ * Get an aliased field name
+ * e.g. fieldName AS newFieldName
+ *
+ * @param $name string Field name
+ * @param $alias string|bool Alias (optional)
+ * @return string SQL name for aliased field. Will not alias a field to its own name
+ */
+ public function fieldNameWithAlias( $name, $alias = false ) {
+ if ( !$alias || (string)$alias === (string)$name ) {
+ return $name;
+ } else {
+ return $name . ' AS ' . $alias; //PostgreSQL needs AS
+ }
+ }
+
+ /**
+ * Gets an array of aliased field names
+ *
+ * @param $fields array( [alias] => field )
+ * @return array of strings, see fieldNameWithAlias()
+ */
+ public function fieldNamesWithAlias( $fields ) {
+ $retval = array();
+ foreach ( $fields as $alias => $field ) {
+ if ( is_numeric( $alias ) ) {
+ $alias = $field;
+ }
+ $retval[] = $this->fieldNameWithAlias( $field, $alias );
+ }
+ return $retval;
+ }
+
/**
* Get the aliased table name clause for a FROM clause
* which might have a JOIN and/or USE INDEX clause
*
* @return string
*/
- function indexName( $index ) {
+ protected function indexName( $index ) {
// Backwards-compatibility hack
$renamed = array(
'ar_usertext_timestamp' => 'usertext_timestamp',
*
* @return string
*/
- function addQuotes( $s ) {
+ public function addQuotes( $s ) {
if ( $s === null ) {
return 'NULL';
} else {
return $name[0] == '"' && substr( $name, -1, 1 ) == '"';
}
- /**
- * Backwards compatibility, identifier quoting originated in DatabasePostgres
- * which used quote_ident which does not follow our naming conventions
- * was renamed to addIdentifierQuotes.
- * @deprecated since 1.18 use addIdentifierQuotes
- *
- * @param $s string
- *
- * @return string
- */
- function quote_ident( $s ) {
- wfDeprecated( __METHOD__, '1.18' );
- return $this->addIdentifierQuotes( $s );
- }
-
- /**
- * Escape string for safe LIKE usage.
- * WARNING: you should almost never use this function directly,
- * instead use buildLike() that escapes everything automatically
- * @deprecated since 1.17, warnings in 1.17, removed in ???
- *
- * @param $s string
- *
- * @return string
- */
- public function escapeLike( $s ) {
- wfDeprecated( __METHOD__, '1.17' );
- return $this->escapeLikeInternal( $s );
- }
-
/**
* @param $s string
* @return string
* @since 1.16
* @return String: fully built LIKE statement
*/
- function buildLike() {
+ public function buildLike() {
$params = func_get_args();
if ( count( $params ) > 0 && is_array( $params[0] ) ) {
*
* @return LikeMatch
*/
- function anyChar() {
+ public function anyChar() {
return new LikeMatch( '_' );
}
*
* @return LikeMatch
*/
- function anyString() {
+ public function anyString() {
return new LikeMatch( '%' );
}
* @param $seqName string
* @return null
*/
- function nextSequenceValue( $seqName ) {
+ public function nextSequenceValue( $seqName ) {
return null;
}
* @param $index
* @return string
*/
- function useIndexClause( $index ) {
+ public function useIndexClause( $index ) {
return '';
}
* a field name or an array of field names
* @param $fname String: Calling function name (use __METHOD__) for logs/profiling
*/
- function replace( $table, $uniqueIndexes, $rows, $fname = 'DatabaseBase::replace' ) {
+ public function replace( $table, $uniqueIndexes, $rows, $fname = 'DatabaseBase::replace' ) {
$quotedTable = $this->tableName( $table );
if ( count( $rows ) == 0 ) {
* @param $fname String: Calling function name (use __METHOD__) for
* logs/profiling
*/
- function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds,
+ public function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds,
$fname = 'DatabaseBase::deleteJoin' )
{
if ( !$conds ) {
*
* @return int
*/
- function textFieldSize( $table, $field ) {
+ public function textFieldSize( $table, $field ) {
$table = $this->tableName( $table );
$sql = "SHOW COLUMNS FROM $table LIKE \"$field\";";
$res = $this->query( $sql, 'DatabaseBase::textFieldSize' );
* @return string Returns the text of the low priority option if it is
* supported, or a blank string otherwise
*/
- function lowPriorityOption() {
+ public function lowPriorityOption() {
return '';
}
*
* @return bool
*/
- function delete( $table, $conds, $fname = 'DatabaseBase::delete' ) {
+ public function delete( $table, $conds, $fname = 'DatabaseBase::delete' ) {
if ( !$conds ) {
throw new DBUnexpectedError( $this, 'DatabaseBase::delete() called with no conditions' );
}
*
* @return ResultWrapper
*/
- function insertSelect( $destTable, $srcTable, $varMap, $conds,
+ public function insertSelect( $destTable, $srcTable, $varMap, $conds,
$fname = 'DatabaseBase::insertSelect',
$insertOptions = array(), $selectOptions = array() )
{
* If the result of the query is not ordered, then the rows to be returned
* are theoretically arbitrary.
*
- * $sql is expected to be a SELECT, if that makes a difference. For
- * UPDATE, limitResultForUpdate should be used.
+ * $sql is expected to be a SELECT, if that makes a difference.
*
* The version provided by default works in MySQL and SQLite. It will very
* likely need to be overridden for most other DBMSes.
*
* @return string
*/
- function limitResult( $sql, $limit, $offset = false ) {
+ public function limitResult( $sql, $limit, $offset = false ) {
if ( !is_numeric( $limit ) ) {
throw new DBUnexpectedError( $this, "Invalid non-numeric limit passed to limitResult()\n" );
}
-
return "$sql LIMIT "
- . ( ( is_numeric( $offset ) && $offset != 0 ) ? "{$offset}," : "" )
- . "{$limit} ";
- }
-
- /**
- * @param $sql
- * @param $num
- * @return string
- */
- function limitResultForUpdate( $sql, $num ) {
- return $this->limitResult( $sql, $num, 0 );
+ . ( ( is_numeric( $offset ) && $offset != 0 ) ? "{$offset}," : "" )
+ . "{$limit} ";
}
/**
* within the UNION construct.
* @return Boolean
*/
- function unionSupportsOrderAndLimit() {
+ public function unionSupportsOrderAndLimit() {
return true; // True for almost every DB supported
}
* @param $all Boolean: use UNION ALL
* @return String: SQL fragment
*/
- function unionQueries( $sqls, $all ) {
+ public function unionQueries( $sqls, $all ) {
$glue = $all ? ') UNION ALL (' : ') UNION (';
return '(' . implode( $glue, $sqls ) . ')';
}
* @param $falseVal String: SQL expression to return if false
* @return String: SQL fragment
*/
- function conditional( $cond, $trueVal, $falseVal ) {
+ public function conditional( $cond, $trueVal, $falseVal ) {
return " (CASE WHEN $cond THEN $trueVal ELSE $falseVal END) ";
}
*
* @return string
*/
- function strreplace( $orig, $old, $new ) {
+ public function strreplace( $orig, $old, $new ) {
return "REPLACE({$orig}, {$old}, {$new})";
}
*
* @return int
*/
- function getServerUptime() {
+ public function getServerUptime() {
return 0;
}
*
* @return bool
*/
- function wasDeadlock() {
+ public function wasDeadlock() {
return false;
}
*
* @return bool
*/
- function wasLockTimeout() {
+ public function wasLockTimeout() {
return false;
}
*
* @return bool
*/
- function wasErrorReissuable() {
+ public function wasErrorReissuable() {
return false;
}
*
* @return bool
*/
- function wasReadOnlyError() {
+ public function wasReadOnlyError() {
return false;
}
*
* @return bool
*/
- function deadlockLoop() {
-
+ public function deadlockLoop() {
$this->begin( __METHOD__ );
$args = func_get_args();
$function = array_shift( $args );
* greater than zero if we waited for some period of time, less than
* zero if we timed out.
*/
- function masterPosWait( DBMasterPos $pos, $timeout ) {
+ public function masterPosWait( DBMasterPos $pos, $timeout ) {
wfProfileIn( __METHOD__ );
if ( !is_null( $this->mFakeSlaveLag ) ) {
*
* @return DBMasterPos, or false if this is not a slave.
*/
- function getSlavePos() {
+ public function getSlavePos() {
if ( !is_null( $this->mFakeSlaveLag ) ) {
$pos = new MySQLMasterPos( 'fake', microtime( true ) - $this->mFakeSlaveLag );
wfDebug( __METHOD__ . ": fake slave pos = $pos\n" );
*
* @return DBMasterPos, or false if this is not a master
*/
- function getMasterPos() {
+ public function getMasterPos() {
if ( $this->mFakeMaster ) {
return new MySQLMasterPos( 'fake', microtime( true ) );
} else {
*
* @param $fname string
*/
- function begin( $fname = 'DatabaseBase::begin' ) {
+ public function begin( $fname = 'DatabaseBase::begin' ) {
$this->query( 'BEGIN', $fname );
$this->mTrxLevel = 1;
}
*
* @param $fname string
*/
- function commit( $fname = 'DatabaseBase::commit' ) {
+ public function commit( $fname = 'DatabaseBase::commit' ) {
if ( $this->mTrxLevel ) {
$this->query( 'COMMIT', $fname );
$this->mTrxLevel = 0;
*
* @param $fname string
*/
- function rollback( $fname = 'DatabaseBase::rollback' ) {
+ public function rollback( $fname = 'DatabaseBase::rollback' ) {
if ( $this->mTrxLevel ) {
$this->query( 'ROLLBACK', $fname, true );
$this->mTrxLevel = 0;
* @param $fname String: calling function name
* @return Boolean: true if operation was successful
*/
- function duplicateTableStructure( $oldName, $newName, $temporary = false,
+ public function duplicateTableStructure( $oldName, $newName, $temporary = false,
$fname = 'DatabaseBase::duplicateTableStructure' )
{
throw new MWException(
*
* @return string
*/
- function timestamp( $ts = 0 ) {
+ public function timestamp( $ts = 0 ) {
return wfTimestamp( TS_MW, $ts );
}
*
* @return string
*/
- function timestampOrNull( $ts = null ) {
+ public function timestampOrNull( $ts = null ) {
if ( is_null( $ts ) ) {
return null;
} else {
*
* @return bool|ResultWrapper
*/
- function resultObject( $result ) {
+ public function resultObject( $result ) {
if ( empty( $result ) ) {
return false;
} elseif ( $result instanceof ResultWrapper ) {
}
}
- /**
- * Return aggregated value alias
- *
- * @param $valuedata
- * @param $valuename string
- *
- * @return string
- */
- function aggregateValue ( $valuedata, $valuename = 'value' ) {
- return $valuename;
- }
-
/**
* Ping the server and try to reconnect if it there is no connection
*
* @return bool Success or failure
*/
- function ping() {
+ public function ping() {
# Stub. Not essential to override.
return true;
}
*
* @return int Database replication lag in seconds
*/
- function getLag() {
+ public function getLag() {
return intval( $this->mFakeSlaveLag );
}
* @param $b string
* @return string
*/
- function encodeBlob( $b ) {
+ public function encodeBlob( $b ) {
return $b;
}
* @param $b string
* @return string
*/
- function decodeBlob( $b ) {
+ public function decodeBlob( $b ) {
return $b;
}
- /**
- * Override database's default connection timeout
- *
- * @param $timeout Integer in seconds
- * @return void
- * @deprecated since 1.19; use setSessionOptions()
- */
- public function setTimeout( $timeout ) {
- wfDeprecated( __METHOD__, '1.19' );
- $this->setSessionOptions( array( 'connTimeout' => $timeout ) );
- }
-
/**
* Override database's default behavior. $options include:
* 'connTimeout' : Set the connection timeout value in seconds.
* generated dynamically using $filename
* @return bool|string
*/
- function sourceFile( $filename, $lineCallback = false, $resultCallback = false, $fname = false ) {
+ public function sourceFile(
+ $filename, $lineCallback = false, $resultCallback = false, $fname = false
+ ) {
wfSuppressWarnings();
$fp = fopen( $filename, 'r' );
wfRestoreWarnings();
*
* @param $vars bool|array mapping variable name to value.
*/
- function setSchemaVars( $vars ) {
+ public function setSchemaVars( $vars ) {
$this->mSchemaVars = $vars;
}
return $this->indexName( $matches[1] );
}
- /**
- * Build a concatenation list to feed into a SQL query
- * @param $stringList Array: list of raw SQL expressions; caller is responsible for any quoting
- * @return String
- */
- function buildConcat( $stringList ) {
- return 'CONCAT(' . implode( ',', $stringList ) . ')';
- }
-
/**
* Check to see if a named lock is available. This is non-blocking.
*