* Fetch the next row from the given result object, in associative array
* form. Fields are retrieved with $row['fieldname'].
*
- * @param $res SQL result object as returned from DatabaseBase::query(), etc.
+ * @param $res ResultWrapper result object as returned from DatabaseBase::query(), etc.
* @return Row object
* @throws DBUnexpectedError Thrown if the database returns an error
*/
/**
* Turns buffering of SQL result sets on (true) or off (false).
* Default is "on" and it should not be changed without good reasons.
+ *
+ * @return bool
*/
function bufferResults( $buffer = null ) {
if ( is_null( $buffer ) ) {
}
}
+ /**
+ * @param $name
+ * @param $value
+ * @return void
+ */
function setLBInfo( $name, $value = null ) {
if ( is_null( $value ) ) {
$this->mLBInfo = $name;
* Return the last query that went through DatabaseBase::query()
* @return String
*/
- function lastQuery() { return $this->mLastQuery; }
+ function lastQuery() {
+ return $this->mLastQuery;
+ }
/**
* Returns true if the connection may have been used for write queries.
* Should return true if unsure.
+ *
+ * @return bool
*/
- function doneWrites() { return $this->mDoneWrites; }
+ function doneWrites() {
+ return $this->mDoneWrites;
+ }
/**
* Is a connection to the database open?
* @return Boolean
*/
- function isOpen() { return $this->mOpened; }
+ function isOpen() {
+ return $this->mOpened;
+ }
/**
* Set a flag for this connection
return $this->$name;
}
+ /**
+ * @return string
+ */
function getWikiID() {
if ( $this->mTablePrefix ) {
return "{$this->mDBname}-{$this->mTablePrefix}";
/**
* Return a path to the DBMS-specific schema, otherwise default to tables.sql
+ *
+ * @return string
*/
public function getSchema() {
global $IP;
/**
* Same as new DatabaseMysql( ... ), kept for backward compatibility
* @deprecated since 1.17
+ *
+ * @return DatabaseMysql
*/
static function newFromParams( $server, $user, $password, $dbName, $flags = 0 ) {
wfDeprecated( __METHOD__ );
/**
* Determine whether a query writes to the DB.
* Should return true if unsure.
+ *
+ * @return bool
*/
function isWriteQuery( $sql ) {
return !preg_match( '/^(?:SELECT|BEGIN|COMMIT|SET|SHOW|\(SELECT)\b/i', $sql );
* ! = raw SQL bit (a function for instance)
* & = filename; reads the file and inserts as a blob
* (we don't use this though...)
+ *
+ * @return array
*/
function prepare( $sql, $func = 'DatabaseBase::prepare' ) {
/* MySQL doesn't support prepared statements (yet), so just
* Execute a prepared query with the various arguments
* @param $prepared String: the prepared sql
* @param $args Mixed: Either an array here, or put scalars as varargs
+ *
+ * @return ResultWrapper
*/
function execute( $prepared, $args = null ) {
if ( !is_array( $args ) ) {
* in the appropriate places.
* @param $query String
* @param $args ...
+ *
+ * @return ResultWrapper
*/
function safeQuery( $query, $args = null ) {
$prepared = $this->prepare( $query, 'DatabaseBase::safeQuery' );
*
* This function exists for historical reasons, DatabaseBase::update() has a more standard
* calling convention and feature set
+ *
+ * @return bool
*/
function set( $table, $var, $value, $cond, $fname = 'DatabaseBase::set' ) {
$table = $this->tableName( $table );
* Determines whether an index exists
* Usually aborts on failure
* If errors are explicitly ignored, returns NULL on failure
+ *
+ * @return bool|null
*/
function indexExists( $table, $index, $fname = 'DatabaseBase::indexExists' ) {
$info = $this->indexInfo( $table, $index, $fname );
/**
* Query whether a given table exists
+ *
+ * @string table
+ *
+ * @return bool
*/
function tableExists( $table ) {
$table = $this->tableName( $table );
/**
* Determines if a given index is unique
+ *
+ * @param $table string
+ * @param $index string
+ *
+ * @return bool
*/
function indexUnique( $table, $index ) {
$indexInfo = $this->indexInfo( $table, $index );
/**
* Makes an encoded list of strings from an array
* @param $a Array
- * @param $mode
+ * @param $mode int
* LIST_COMMA - comma separated, no field names
* LIST_AND - ANDed WHERE clause (without the WHERE)
* LIST_OR - ORed WHERE clause (without the WHERE)
* Bitwise operations
*/
+ /**
+ * @param $field
+ * @return string
+ */
function bitNot( $field ) {
return "(~$field)";
}
+ /**
+ * @param $fieldLeft
+ * @param $fieldRight
+ * @return string
+ */
function bitAnd( $fieldLeft, $fieldRight ) {
return "($fieldLeft & $fieldRight)";
}
+ /**
+ * @param $fieldLeft
+ * @param $fieldRight
+ * @return string
+ */
function bitOr( $fieldLeft, $fieldRight ) {
return "($fieldLeft | $fieldRight)";
}
/**
* Get the name of an index in a given table
+ *
+ * @param $index
+ *
+ * @return string
*/
function indexName( $index ) {
// Backwards-compatibility hack
/**
* If it's a string, adds quotes and backslashes
* Otherwise returns as-is
+ *
+ * @param $s string
+ *
+ * @return string
*/
function addQuotes( $s ) {
if ( $s === null ) {
* MySQL uses `backticks` while basically everything else uses double quotes.
* Since MySQL is the odd one out here the double quotes are our generic
* and we implement backticks in DatabaseMysql.
+ *
+ * @return string
*/
public function addIdentifierQuotes( $s ) {
return '"' . str_replace( '"', '""', $s ) . '"';
/**
* Returns if the given identifier looks quoted or not according to
* the database convention for quoting identifiers .
+ *
+ * @param $name string
+ *
* @return boolean
*/
public function isQuotedIdentifier( $name ) {
* which used quote_ident which does not follow our naming conventions
* was renamed to addIdentifierQuotes.
* @deprecated since 1.18 use addIdentifierQuotes
+ *
+ * @return string
*/
function quote_ident( $s ) {
wfDeprecated( __METHOD__ );
/**
* Returns a token for buildLike() that denotes a '_' to be used in a LIKE query
+ *
+ * @return LikeMatch
*/
function anyChar() {
return new LikeMatch( '_' );
/**
* Returns a token for buildLike() that denotes a '%' to be used in a LIKE query
+ *
+ * @rerturn LikeMatch
*/
function anyString() {
return new LikeMatch( '%' );
* Source items may be literals rather than field names, but strings should be quoted with DatabaseBase::addQuotes()
* $conds may be "*" to copy the whole table
* srcTable may be an array of tables.
+ *
+ * @return ResultWrapper
*/
function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = 'DatabaseBase::insertSelect',
$insertOptions = array(), $selectOptions = array() )
* @param $sql String: SQL query we will append the limit too
* @param $limit Integer: the SQL limit
* @param $offset Integer the SQL offset (default false)
+ *
+ * @return string
*/
function limitResult( $sql, $limit, $offset = false ) {
if ( !is_numeric( $limit ) ) {
* @param $orig String: column to modify
* @param $old String: column to seek
* @param $new String: column to replace with
+ *
+ * @return string
*/
function strreplace( $orig, $old, $new ) {
return "REPLACE({$orig}, {$old}, {$new})";
/**
* Determines if the last failure was due to a deadlock
* STUB
+ *
+ * @return bool
*/
function wasDeadlock() {
return false;
* Determines if the last query error was something that should be dealt
* with by pinging the connection and reissuing the query.
* STUB
+ *
+ * @return bool
*/
function wasErrorReissuable() {
return false;
/**
* Determines if the last failure was due to the database being read-only.
* STUB
+ *
+ * @return bool
*/
function wasReadOnlyError() {
return false;
/**
* Get the position of the master from SHOW SLAVE STATUS
+ *
+ * @return MySQLMasterPos|false
*/
function getSlavePos() {
if ( !is_null( $this->mFakeSlaveLag ) ) {
/**
* Get the position of the master from SHOW MASTER STATUS
+ *
+ * @return MySQLMasterPos|false
*/
function getMasterPos() {
if ( $this->mFakeMaster ) {
/**
* Return MW-style timestamp used for MySQL schema
+ *
+ * @return string
*/
function timestamp( $ts = 0 ) {
return wfTimestamp( TS_MW, $ts );
/**
* Local database timestamp format or null
+ *
+ * @return string
*/
function timestampOrNull( $ts = null ) {
if ( is_null( $ts ) ) {
/**
* @todo document
+ *
+ * @return ResultWrapper
*/
function resultObject( $result ) {
if ( empty( $result ) ) {
/**
* Get status information from SHOW STATUS in an associative array
+ *
+ * @return array
*/
function getStatus( $which = "%" ) {
$res = $this->query( "SHOW STATUS LIKE '{$which}'" );
/**
* Return the maximum number of items allowed in a list, or 0 for unlimited.
+ *
+ * return int
*/
function maxListLen() {
return 0;