$this->mTitle->mRestrictions = explode( ',', trim( $s->cur_restrictions ) );
$this->mTitle->mRestrictionsLoaded = true;
} else { # oldid set, retrieve historical version
- $s = $dbr->getArray( 'old', $this->getOldContentFields(), array( 'old_id' => $oldid ),
+ $s = $dbr->selectRow( 'old', $this->getOldContentFields(), array( 'old_id' => $oldid ),
$fname, $this->getSelectOptions() );
if ( $s === false ) {
return;
$fname = 'Article::loadLastEdit';
$dbr =& $this->getDB();
- $s = $dbr->getArray( 'cur',
+ $s = $dbr->selectRow( 'cur',
array( 'cur_user','cur_user_text','cur_timestamp', 'cur_comment','cur_minor_edit' ),
array( 'cur_id' => $this->getID() ), $fname, $this->getSelectOptions() );
$isminor = ( $isminor && $wgUser->getID() ) ? 1 : 0;
- $dbw->insertArray( 'cur', array(
+ $dbw->insert( 'cur', array(
'cur_id' => $cur_id,
'cur_namespace' => $ns,
'cur_title' => $ttl,
# The talk page isn't in the regular link tables, so we need to update manually:
$talkns = $ns ^ 1; # talk -> normal; normal -> talk
- $dbw->updateArray( 'cur', array('cur_touched' => $dbw->timestamp($now) ),
+ $dbw->update( 'cur', array('cur_touched' => $dbw->timestamp($now) ),
array( 'cur_namespace' => $talkns, 'cur_title' => $ttl ), $fname );
# standard deferred updates
$dbw =& wfGetDB( DB_MASTER );
$ns = $this->mTitle->getNamespace();
$title = $this->mTitle->getDBkey();
- $obj = $dbw->getArray( 'old',
+ $obj = $dbw->selectRow( 'old',
array( 'old_text','old_flags'),
array( 'old_namespace' => $ns, 'old_title' => $title,
'old_timestamp' => $dbw->timestamp($edittime)),
$won = wfInvertTimestamp( $now );
# First update the cur row
- $dbw->updateArray( 'cur',
+ $dbw->update( 'cur',
array( /* SET */
'cur_text' => $text,
'cur_comment' => $summary,
# This overwrites $oldtext if revision compression is on
$flags = Article::compressRevisionText( $oldtext );
- $dbw->insertArray( 'old',
+ $dbw->insert( 'old',
array(
'old_id' => $dbw->nextSequenceValue( 'old_old_id_seq' ),
'old_namespace' => $this->mTitle->getNamespace(),
if ( $confirm ) {
$dbw =& wfGetDB( DB_MASTER );
- $dbw->updateArray( 'cur',
+ $dbw->update( 'cur',
array( /* SET */
'cur_touched' => $dbw->timestamp(),
'cur_restrictions' => (string)$limit
$dbr =& $this->getDB();
$ns = $this->mTitle->getNamespace();
$title = $this->mTitle->getDBkey();
- $old = $dbr->getArray( 'old',
+ $old = $dbr->selectRow( 'old',
array( 'old_text', 'old_flags' ),
array(
'old_namespace' => $ns,
}
# Fetch cur_text
- $s = $dbr->getArray( 'cur',
+ $s = $dbr->selectRow( 'cur',
array( 'cur_text' ),
array(
'cur_namespace' => $ns,
$linkID = $titleObj->getArticleID();
$brokenLinks[] = array( 'bl_from' => $linkID, 'bl_to' => $t );
}
- $dbw->insertArray( 'brokenlinks', $brokenLinks, $fname, 'IGNORE' );
+ $dbw->insert( 'brokenlinks', $brokenLinks, $fname, 'IGNORE' );
# Delete live links
$dbw->delete( 'links', array( 'l_to' => $id ) );
$n = $this->mTitle->getNamespace();
# Get the last editor, lock table exclusively
- $s = $dbw->getArray( 'cur',
+ $s = $dbw->selectRow( 'cur',
array( 'cur_id','cur_user','cur_user_text','cur_comment' ),
array( 'cur_title' => $tt, 'cur_namespace' => $n ),
$fname, 'FOR UPDATE'
}
# Get the last edit not by this guy
- $s = $dbw->getArray( 'old',
+ $s = $dbw->selectRow( 'old',
array( 'old_text','old_user','old_user_text','old_timestamp','old_flags' ),
array(
'old_namespace' => $n,
if ( $bot ) {
# Mark all reverted edits as bot
- $dbw->updateArray( 'recentchanges',
+ $dbw->update( 'recentchanges',
array( /* SET */
'rc_bot' => 1
), array( /* WHERE */
$fname = 'Article::checkTouched';
$id = $this->getID();
$dbr =& $this->getDB();
- $s = $dbr->getArray( 'cur', array( 'cur_touched', 'cur_is_redirect' ),
+ $s = $dbr->selectRow( 'cur', array( 'cur_touched', 'cur_is_redirect' ),
array( 'cur_id' => $id ), $fname, $this->getSelectOptions() );
if( $s !== false ) {
$this->mTouched = wfTimestamp(TS_MW,$s->cur_touched);
if ( $numRows ) {
# Update article
$fields['cur_is_new'] = 0;
- $dbw->updateArray( 'cur', $fields, array( 'cur_namespace' => $ns, 'cur_title' => $dbkey ), $fname );
+ $dbw->update( 'cur', $fields, array( 'cur_namespace' => $ns, 'cur_title' => $dbkey ), $fname );
} else {
# Insert new article
$fields['cur_is_new'] = 1;
$fields['cur_namespace'] = $ns;
$fields['cur_title'] = $dbkey;
$fields['cur_random'] = $rand = wfRandom();
- $dbw->insertArray( 'cur', $fields, $fname );
+ $dbw->insert( 'cur', $fields, $fname );
}
wfProfileOut( $fname );
}
function insert()
{
$dbw =& wfGetDB( DB_MASTER );
- $dbw->insertArray( 'ipblocks',
+ $dbw->insert( 'ipblocks',
array(
'ipb_address' => $this->mAddress,
'ipb_user' => $this->mUser,
$this->mExpiry = Block::getAutoblockExpiry( $this->mTimestamp );
$dbw =& wfGetDB( DB_MASTER );
- $dbw->updateArray( 'ipblocks',
+ $dbw->update( 'ipblocks',
array( /* SET */
'ipb_timestamp' => $dbw->timestamp($this->mTimestamp),
'ipb_expiry' => $dbw->timestamp($this->mExpiry),
*/
require_once( 'CacheManager.php' );
-/** @todo document */
+/** See Database::makeList() */
define( 'LIST_COMMA', 0 );
-/** @todo document */
define( 'LIST_AND', 1 );
-/** @todo document */
define( 'LIST_SET', 2 );
-/** @todo document */
define( 'LIST_NAMES', 3);
/** Number of times to re-try an operation in case of deadlock */
* @param mixed $res A SQL result
*/
/**
- * @todo document
+ * Free a result object
*/
function freeResult( $res ) {
if ( !@/**/mysql_free_result( $res ) ) {
}
/**
- * @todo FIXME: HACK HACK HACK HACK debug
+ * Fetch the next row from the given result object, in object form
*/
function fetchObject( $res ) {
@/**/$row = mysql_fetch_object( $res );
- # FIXME: HACK HACK HACK HACK debug
if( mysql_errno() ) {
wfDebugDieBacktrace( 'Error in fetchObject(): ' . htmlspecialchars( mysql_error() ) );
}
}
/**
- * @todo document
+ * Fetch the next row from the given result object
+ * Returns an array
*/
function fetchRow( $res ) {
@/**/$row = mysql_fetch_array( $res );
}
/**
- * @todo document
+ * Get the number of rows in a result object
*/
function numRows( $res ) {
@/**/$n = mysql_num_rows( $res );
}
/**
- * @todo document
+ * Get the number of fields in a result object
+ * See documentation for mysql_num_fields()
*/
function numFields( $res ) { return mysql_num_fields( $res ); }
/**
- * @todo document
+ * Get a field name in a result object
+ * See documentation for mysql_field_name()
*/
function fieldName( $res, $n ) { return mysql_field_name( $res, $n ); }
+
/**
- * @todo document
+ * Get the inserted value of an auto-increment row
+ *
+ * The value inserted should be fetched from nextSequenceValue()
+ *
+ * Example:
+ * $id = $dbw->nextSequenceValue('cur_cur_id_seq');
+ * $dbw->insert('cur',array('cur_id' => $id));
+ * $id = $dbw->insertId();
*/
function insertId() { return mysql_insert_id( $this->mConn ); }
+
/**
- * @todo document
+ * Change the position of the cursor in a result object
+ * See mysql_data_seek()
*/
function dataSeek( $res, $row ) { return mysql_data_seek( $res, $row ); }
+
/**
- * @todo document
+ * Get the last error number
+ * See mysql_errno()
*/
function lastErrno() { return mysql_errno(); }
+
/**
- * @todo document
+ * Get a description of the last error
+ * See mysql_error() for more details
*/
function lastError() { return mysql_error(); }
+
/**
- * @todo document
+ * Get the number of rows affected by the last write query
+ * See mysql_affected_rows() for more details
*/
function affectedRows() { return mysql_affected_rows( $this->mConn ); }
/**#@-*/ // end of template : @param $result
return !!$this->query( $sql, DB_MASTER, $fname );
}
- /**
- * @todo document
- */
- function getField( $table, $var, $cond='', $fname = 'Database::getField', $options = array() ) {
- return $this->selectField( $table, $var, $cond, $fname = 'Database::get', $options = array() );
- }
-
/**
* Simple SELECT wrapper, returns a single field, input must be encoded
* Usually aborts on failure
}
return $this->query( $sql, $fname );
}
-
- /**
- * @todo document
- */
- function getArray( $table, $vars, $conds, $fname = 'Database::getArray', $options = array() ) {
- return $this->selectRow( $table, $vars, $conds, $fname, $options );
- }
-
/**
* Single row SELECT wrapper
/**
- * @todo document
+ * Get information about an index into an object
+ * Returns false if the index does not exist
*/
function indexInfo( $table, $index, $fname = 'Database::indexInfo' ) {
# SHOW INDEX works in MySQL 3.23.58, but SHOW INDEXES does not.
}
/**
- * @param $table
- * @todo document
+ * Query whether a given table exists
*/
function tableExists( $table ) {
$table = $this->tableName( $table );
}
/**
+ * mysql_fetch_field() wrapper
+ * Returns false if the field doesn't exist
+ *
* @param $table
* @param $field
- * @todo document
*/
function fieldInfo( $table, $field ) {
$table = $this->tableName( $table );
}
/**
- * @todo document
+ * mysql_field_type() wrapper
*/
function fieldType( $res, $index ) {
return mysql_field_type( $res, $index );
}
/**
- * @todo document
+ * Determines if a given index is unique
*/
function indexUnique( $table, $index ) {
$indexInfo = $this->indexInfo( $table, $index );
return !$indexInfo->Non_unique;
}
- /**
- * @todo document
- */
- function insertArray( $table, $a, $fname = 'Database::insertArray', $options = array() ) {
- return $this->insert( $table, $a, $fname, $options );
- }
-
/**
* INSERT wrapper, inserts an array into a table
*
return !!$this->query( $sql, $fname );
}
- /**
- * @todo document
- */
- function updateArray( $table, $values, $conds, $fname = 'Database::updateArray' ) {
- return $this->update( $table, $values, $conds, $fname );
- }
-
/**
* UPDATE wrapper, takes a condition array and a SET array
*/
}
/**
- * @todo document
+ * Change the current database
*/
function selectDB( $db ) {
$this->mDBname = $db;
}
/**
- * @todo document
+ * Starts a timer which will kill the DB thread after $timeout seconds
*/
function startTimer( $timeout ) {
global $IP;
}
/**
- * Does nothing at all
- * @todo document
+ * Stop a timer started by startTimer()
+ * Currently unimplemented.
+ *
*/
function stopTimer() { }
/**
+ * Format a table name ready for use in constructing an SQL query
+ *
+ * This does two important things: it quotes table names which as necessary,
+ * and it adds a table prefix if there is one.
+ *
+ * All functions of this object which require a table name call this function
+ * themselves. Pass the canonical name to such functions. This is only needed
+ * when calling query() directly.
+ *
* @param string $name database table name
- * @todo document
*/
function tableName( $name ) {
global $wgSharedDB;
}
/**
- * @todo document
+ * Fetch a number of table names into an array
+ * This is handy when you need to construct SQL for joins
+ *
+ * Example:
+ * extract($dbr->tableNames('user','watchlist'));
+ * $sql = "SELECT wl_namespace,wl_title FROM $watchlist,$user
+ * WHERE wl_user=user_id AND wl_user=$nameWithQuotes";
*/
function tableNames() {
$inArray = func_get_args();
}
/**
+ * DELETE query wrapper
+ *
* Use $conds == "*" to delete all rows
- * @todo document
*/
function delete( $table, $conds, $fname = 'Database::delete' ) {
if ( !$conds ) {
}
/**
- * @todo document
+ * Construct a LIMIT query with optional offset
+ * This is used for query pages
*/
function limitResult($limit,$offset) {
return ' LIMIT '.(is_numeric($offset)?"{$offset},":"")."{$limit} ";
}
/**
- * @todo document
+ * Determines if the last failure was due to a deadlock
*/
function wasDeadlock() {
return $this->lastErrno() == 1213;
}
/**
- * @todo document
+ * Perform a deadlock-prone transaction.
+ *
+ * This function invokes a callback function to perform a set of write
+ * queries. If a deadlock occurs during the processing, the transaction
+ * will be rolled back and the callback function will be called again.
+ *
+ * Usage:
+ * $dbw->deadlockLoop( callback, ... );
+ *
+ * Extra arguments are passed through to the specified callback function.
+ *
+ * Returns whatever the callback function returned on its successful,
+ * iteration, or false on error, for example if the retry limit was
+ * reached.
*/
function deadlockLoop() {
$myFname = 'Database::deadlockLoop';
/**
* Do a SELECT MASTER_POS_WAIT()
- * @todo document
+ *
+ * @param string $file the binlog file
+ * @param string $pos the binlog position
+ * @param integer $timeout the maximum number of seconds to wait for synchronisation
*/
function masterPosWait( $file, $pos, $timeout ) {
$encFile = $this->strencode( $file );
{
$db =& wfGetDB( $dbi );
if ( $db !== false ) {
- return $db->getField( $table, $var, $cond );
+ return $db->selectField( $table, $var, $cond );
} else {
return false;
}
function wfInsertArray( $table, $array, $fname = 'wfInsertArray', $dbi = DB_MASTER ) {
$db =& wfGetDB( $dbi );
if ( $db !== false ) {
- return $db->insertArray( $table, $array, $fname );
+ return $db->insert( $table, $array, $fname );
} else {
return false;
}
function wfUpdateArray( $table, $values, $conds, $fname = 'wfUpdateArray', $dbi = DB_MASTER ) {
$db =& wfGetDB( $dbi );
if ( $db !== false ) {
- $db->updateArray( $table, $values, $conds, $fname );
+ $db->update( $table, $values, $conds, $fname );
return true;
} else {
return false;
return false;*/
}
- function insertArray( $table, $a, $fname = 'Database::insertArray', $options = array() ) {
+ function insert( $table, $a, $fname = 'Database::insert', $options = array() ) {
# PostgreSQL doesn't support options
# We have a go at faking one of them
# TODO: DELAYED, LOW_PRIORITY
$a = array( $a );
}
foreach ( $a as $row ) {
- parent::insertArray( $table, $row, $fname, array() );
+ parent::insert( $table, $row, $fname, array() );
}
$this->ignoreErrors( $oldIgnore );
$retVal = true;
* Return the next in a sequence, save the value for retrieval via insertId()
*/
function nextSequenceValue( $seqName ) {
- $value = $this->getField(''," nextval('" . $seqName . "')");
+ $value = $this->selectField(''," nextval('" . $seqName . "')");
$this->mInsertId = $value;
return $value;
}
$this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a>";
$id = $wgTitle->getArticleID();
- $s = $dbr->getArray( 'cur', array( 'cur_text', 'cur_user_text', 'cur_comment' ),
+ $s = $dbr->selectRow( 'cur', array( 'cur_text', 'cur_user_text', 'cur_comment' ),
array( 'cur_id' => $id ), $fname );
if ( $s === false ) {
wfDebug( "Unable to load cur_id $id\n" );
$this->mNewUser = $s->cur_user_text;
$this->mNewComment = $s->cur_comment;
} else {
- $s = $dbr->getArray( 'old', array( 'old_namespace','old_title','old_timestamp', 'old_text',
+ $s = $dbr->selectRow( 'old', array( 'old_namespace','old_title','old_timestamp', 'old_text',
'old_flags','old_user_text','old_comment' ), array( 'old_id' => $this->mNewid ), $fname );
if ( $s === false ) {
$this->mNewComment = $s->old_comment;
}
if ( 0 == $this->mOldid ) {
- $s = $dbr->getArray( 'old',
+ $s = $dbr->selectRow( 'old',
array( 'old_namespace','old_title','old_timestamp','old_text', 'old_flags','old_user_text','old_comment' ),
array( /* WHERE */
'old_namespace' => $this->mNewPage->getNamespace(),
return false;
}
} else {
- $s = $dbr->getArray( 'old',
+ $s = $dbr->selectRow( 'old',
array( 'old_namespace','old_title','old_timestamp','old_text','old_flags','old_user_text','old_comment'),
array( 'old_id' => $this->mOldid ),
$fname
$fname = 'EditPage::mergeChangesInto';
$oldDate = $this->edittime;
$dbw =& wfGetDB( DB_MASTER );
- $obj = $dbw->getArray( 'cur', array( 'cur_text' ), array( 'cur_id' => $this->mTitle->getArticleID() ),
+ $obj = $dbw->selectRow( 'cur', array( 'cur_text' ), array( 'cur_id' => $this->mTitle->getArticleID() ),
$fname, 'FOR UPDATE' );
$yourtext = $obj->cur_text;
$ns = $this->mTitle->getNamespace();
$title = $this->mTitle->getDBkey();
- $obj = $dbw->getArray( 'old',
+ $obj = $dbw->selectRow( 'old',
array( 'old_text','old_flags'),
array( 'old_namespace' => $ns, 'old_title' => $title,
'old_timestamp' => $dbw->timestamp($oldDate)),
# Test to see if the row exists using INSERT IGNORE
# This avoids race conditions by locking the row until the commit, and also
# doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
- $dbw->insertArray( 'image',
+ $dbw->insert( 'image',
array(
'img_name' => $name,
'img_size'=> $size,
if ( $id == 0 ) {
$seqVal = $dbw->nextSequenceValue( 'cur_cur_id_seq' );
- $dbw->insertArray( 'cur',
+ $dbw->insert( 'cur',
array(
'cur_id' => $seqVal,
'cur_namespace' => NS_IMAGE,
} else {
# Collision, this is an update of an image
# Get current image row for update
- $s = $dbw->getArray( 'image', array( 'img_name','img_size','img_timestamp','img_description',
+ $s = $dbw->selectRow( 'image', array( 'img_name','img_size','img_timestamp','img_description',
'img_user','img_user_text' ), array( 'img_name' => $name ), $fname, 'FOR UPDATE' );
# Insert it into oldimage
- $dbw->insertArray( 'oldimage',
+ $dbw->insert( 'oldimage',
array(
'oi_name' => $s->img_name,
'oi_archive_name' => $oldver,
);
# Update the current image row
- $dbw->updateArray( 'image',
+ $dbw->update( 'image',
array( /* SET */
'img_size' => $size,
'img_timestamp' => $dbw->timestamp(),
$oldver = wfTimestampNow() . "!{$name}";
$dbr =& wfGetDB( DB_SLAVE );
- $size = $dbr->getField( 'oldimage', 'oi_size', 'oi_archive_name=\'' .
+ $size = $dbr->selectField( 'oldimage', 'oi_size', 'oi_archive_name=\'' .
$dbr->strencode( $oldimage ) . "'" );
if ( ! rename( $curfile, "${archive}/{$oldver}" ) ) {
$options = array();
}
- $id = $db->getField( 'cur', 'cur_id', array( 'cur_namespace' => $ns, 'cur_title' => $t ), $fname, $options );
+ $id = $db->selectField( 'cur', 'cur_id', array( 'cur_namespace' => $ns, 'cur_title' => $t ), $fname, $options );
if ( !$id ) {
$id = 0;
}
$db =& wfGetDB( DB_SLAVE );
$options = '';
}
- $raw = $db->getField( 'linkscc', 'lcc_cacheobj', array( 'lcc_pageid' => $id ), $fname, $options );
+ $raw = $db->selectField( 'linkscc', 'lcc_cacheobj', array( 'lcc_pageid' => $id ), $fname, $options );
if ( $raw === false ) {
return false;
}
# The link cache was constructed without FOR UPDATE, so there may be collisions
# Ignoring for now, I'm not sure if that causes problems or not, but I'm fairly
# sure it's better than without IGNORE
- $dbw->insertArray('links', $arr, $fname, array('IGNORE'));
+ $dbw->insert('links', $arr, $fname, array('IGNORE'));
}
#------------------------------------------------------------------------------
'bl_from'=>$this->mId,
'bl_to'=>$blt));
}
- $dbw->insertArray( 'brokenlinks',$arr,$fname,array('IGNORE'));
+ $dbw->insert( 'brokenlinks',$arr,$fname,array('IGNORE'));
}
#------------------------------------------------------------------------------
'il_from'=>$this->mId,
'il_to'=>$iname));
}
- $dbw->insertArray($imagelinks, $arr, $fname, array('IGNORE'));
+ $dbw->insert('imagelinks', $arr, $fname, array('IGNORE'));
}
#------------------------------------------------------------------------------
'cl_to'=>$dbw->strencode( $cname ),
'cl_sortkey'=>$dbw->strencode( $sortkey )));
}
- $dbw->insertArray($categorylinks,$arr,$fname,array('IGNORE'));
+ $dbw->insert('categorylinks',$arr,$fname,array('IGNORE'));
}
}
'l_from'=>$this->mId,
'l_to'=>$lid));
}
- $dbw->insertArray($links,$arr,$fname,array('IGNORE'));
+ $dbw->insert('links',$arr,$fname,array('IGNORE'));
}
$sql = "DELETE FROM $brokenlinks WHERE bl_from={$this->mId}";
'bl_from'=>$this->mId,
'bl_to'=>$blt));
}
- $dbw->insertArray($brokenlinks,$arr,$fname,array('IGNORE'));
+ $dbw->insert('brokenlinks',$arr,$fname,array('IGNORE'));
}
$sql = "DELETE FROM $imagelinks WHERE il_from={$this->mId}";
array_push($arr,array(
'il_from'=>$this->mId,
'il_to'=>$dbw->strencode( $iname )));
- $dbw->insertArray($imagelinks,$arr,$fname,array('IGNORE'));
+ $dbw->insert('imagelinks',$arr,$fname,array('IGNORE'));
}
if( $wgUseCategoryMagic ) {
'cl_to'=>$dbw->strencode( $cname ),
'cl_sortkey'=>$dbw->strencode( $sortkey )));
}
- $dbw->insertArray($categorylinks,$arr,$fname,array('IGNORE'));
+ $dbw->insert('categorylinks',$arr,$fname,array('IGNORE'));
}
}
$this->fixBrokenLinks();
$fname, 'FOR UPDATE' );
if ( 0 == $dbw->numRows( $res ) ) { return; }
- # Ignore errors. If a link existed in both the brokenlinks table and the links
- # table, that's an error which can be fixed at this stage by simply ignoring collisions
$arr=array();
$now = $dbw->timestamp();
$sql2 = "UPDATE $cur SET cur_touched='{$now}' WHERE cur_id IN (";
$sql2 .= $row->bl_from;
}
$sql2 .= ')';
- $dbw->insertArray($links,$arr,$fname,array('IGNORE'));
+
+ # Ignore errors. If a link existed in both the brokenlinks table and the links
+ # table, that's an error which can be fixed at this stage by simply ignoring collisions
+ $dbw->insert('links',$arr,$fname,array('IGNORE'));
$dbw->query( $sql2, $fname );
$dbw->delete( 'brokenlinks', array( 'bl_to' => $this->mTitle ), $fname );
}
$uid = $wgUser->getID();
$this->timestamp = $now = wfTimestampNow();
- $dbw->insertArray( 'logging',
+ $dbw->insert( 'logging',
array(
'log_type' => $this->type,
'log_action' => $this->action,
$this->md5 = md5( $this->tex );
$dbr =& wfGetDB( DB_SLAVE );
- $rpage = $dbr->getArray( 'math',
+ $rpage = $dbr->selectRow( 'math',
array( 'math_outputhash','math_html_conservativeness','math_html','math_mathml' ),
array( 'math_inputhash' => pack("H32", $this->md5)), # Binary packed, not hex
$fname
# If it wasn't in the cache, load each message from the DB individually
if ( !$message ) {
$dbr =& wfGetDB( DB_SLAVE );
- $result = $dbr->getArray( 'cur', array('cur_text'),
+ $result = $dbr->selectRow( 'cur', array('cur_text'),
array( 'cur_namespace' => NS_MEDIAWIKI, 'cur_title' => $title ),
'MessageCache::get' );
if ( $result ) {
if ( -1 != $wgNumberOfArticles ) return;
$dbr =& wfGetDB( DB_SLAVE );
- $s = $dbr->getArray( 'site_stats',
+ $s = $dbr->selectRow( 'site_stats',
array( 'ss_total_views', 'ss_total_edits', 'ss_good_articles' ),
array( 'ss_row_id' => 1 ), $fname
);
$rc = $dbw->affectedRows();
if( $rc == 0) {
- $dbw->insertArray($profiling,array(
+ $dbw->insert('profiling',array(
'pf_name'=>$name,
'pf_count'=>$eventCount,
'pf_time'=>$timeSum),
$this->mAttribs['rc_cur_time']=$dbw->timestamp($this->mAttribs['rc_cur_time']);
# Insert new row
- $dbw->insertArray( 'recentchanges', $this->mAttribs, $fname );
+ $dbw->insert( 'recentchanges', $this->mAttribs, $fname );
# Update old rows, if necessary
if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
$curId = $this->mAttribs['rc_cur_id'];
# Update rc_this_oldid for the entries which were current
- $dbw->updateArray( 'recentchanges',
+ $dbw->update( 'recentchanges',
array( /* SET */
'rc_this_oldid' => $oldid
), array( /* WHERE */
);
# Update rc_cur_time
- $dbw->updateArray( 'recentchanges', array( 'rc_cur_time' => $now ),
+ $dbw->update( 'recentchanges', array( 'rc_cur_time' => $now ),
array( 'rc_cur_id' => $curId ), $fname );
}
$dbw =& wfGetDB( DB_MASTER );
- $dbw->updateArray( 'recentchanges',
+ $dbw->update( 'recentchanges',
array( /* SET */
'rc_patrolled' => 1
), array( /* WHERE */
# Strip wiki '' and '''
$text = preg_replace( "/''[']*/", " ", $text );
wfProfileOut( "$fname-regexps" );
- $db->replace( $searchindex, array(array('si_page')),
- array(
- 'si_page' => $this->mId,
- 'si_title' => $db->strencode( Title::indexTitle( $this->mNamespace, $this->mTitle ) ),
- 'si_text' => $db->strencode( $text )
- ), 'SearchUpdate::doUpdate' );
+ $db->replace( 'searchindex', array(array('si_page')),
+ array(
+ 'si_page' => $this->mId,
+ 'si_title' => $db->strencode( Title::indexTitle( $this->mNamespace, $this->mTitle ) ),
+ 'si_text' => $db->strencode( $text )
+ ), 'SearchUpdate::doUpdate' );
wfProfileOut( $fname );
}
}
$redir = $redirect->matchStart( $text ) ? 1 : 0;
$rand = wfRandom();
- $dbw->insertArray( 'cur', array(
+ $dbw->insert( 'cur', array(
'cur_id' => $dbw->nextSequenceValue( 'cur_cur_id_seq' ),
'cur_namespace' => $namespace,
'cur_title' => $ttl,
/* static */ function newFromID( $id ) {
$fname = 'Title::newFromID';
$dbr =& wfGetDB( DB_SLAVE );
- $row = $dbr->getArray( 'cur', array( 'cur_namespace', 'cur_title' ),
+ $row = $dbr->selectRow( 'cur', array( 'cur_namespace', 'cur_title' ),
array( 'cur_id' => $id ), $fname );
if ( $row !== false ) {
$title = Title::makeTitle( $row->cur_namespace, $row->cur_title );
$fname = 'Title::nameOf';
$dbr =& wfGetDB( DB_SLAVE );
- $s = $dbr->getArray( 'cur', array( 'cur_namespace','cur_title' ), array( 'cur_id' => $id ), $fname );
+ $s = $dbr->selectRow( 'cur', array( 'cur_namespace','cur_title' ), array( 'cur_id' => $id ), $fname );
if ( $s === false ) { return NULL; }
$n = Title::makeName( $s->cur_namespace, $s->cur_title );
if ( ! $this->mRestrictionsLoaded ) {
$dbr =& wfGetDB( DB_SLAVE );
- $res = $dbr->getField( 'cur', 'cur_restrictions', 'cur_id='.$id );
+ $res = $dbr->selectField( 'cur', 'cur_restrictions', 'cur_id='.$id );
$this->mRestrictions = explode( ',', trim( $res ) );
$this->mRestrictionsLoaded = true;
}
function isDeleted() {
$fname = 'Title::isDeleted';
$dbr =& wfGetDB( DB_SLAVE );
- $n = $dbr->getField( 'archive', 'COUNT(*)', array( 'ar_namespace' => $this->getNamespace(),
+ $n = $dbr->selectField( 'archive', 'COUNT(*)', array( 'ar_namespace' => $this->getNamespace(),
'ar_title' => $this->getDBkey() ), $fname );
return (int)$n;
}
function invalidateCache() {
$now = wfTimestampNow();
$dbw =& wfGetDB( DB_MASTER );
- $success = $dbw->updateArray( 'cur',
+ $success = $dbw->update( 'cur',
array( /* SET */
'cur_touched' => $dbw->timestamp()
), array( /* WHERE */
$links = $dbw->tableName( 'links' );
# Change the name of the target page:
- $dbw->updateArray( 'cur',
+ $dbw->update( 'cur',
/* SET */ array(
'cur_touched' => $dbw->timestamp($now),
'cur_namespace' => $nt->getNamespace(),
# by definition if we've got here it's rather uninteresting.
$redirectText = $wgMwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n";
- $dbw->updateArray( 'cur',
+ $dbw->update( 'cur',
/* SET */ array(
'cur_touched' => $dbw->timestamp($now),
'cur_timestamp' => $dbw->timestamp($now),
# Fix the redundant names for the past revisions of the target page.
# The redirect should have no old revisions.
- $dbw->updateArray(
+ $dbw->update(
/* table */ 'old',
/* SET */ array(
'old_namespace' => $nt->getNamespace(),
# Now, we record the link from the redirect to the new title.
# It should have no other outgoing links...
$dbw->delete( 'links', array( 'l_from' => $newid ) );
- $dbw->insertArray( 'links', array( 'l_from' => $newid, 'l_to' => $oldid ) );
+ $dbw->insert( 'links', array( 'l_from' => $newid, 'l_to' => $oldid ) );
# Clear linkscc
LinkCache::linksccClearLinksTo( $oldid );
$rand = wfRandom();
# Rename cur entry
- $dbw->updateArray( 'cur',
+ $dbw->update( 'cur',
/* SET */ array(
'cur_touched' => $now,
'cur_namespace' => $nt->getNamespace(),
$wgLinkCache->clearLink( $nt->getPrefixedDBkey() );
# Insert redirect
- $dbw->insertArray( 'cur', array(
+ $dbw->insert( 'cur', array(
'cur_id' => $dbw->nextSequenceValue('cur_cur_id_seq'),
'cur_namespace' => $this->getNamespace(),
'cur_title' => $this->getDBkey(),
$wgLinkCache->clearLink( $this->getPrefixedDBkey() );
# Rename old entries
- $dbw->updateArray(
+ $dbw->update(
/* table */ 'old',
/* SET */ array(
'old_namespace' => $nt->getNamespace(),
Article::onArticleCreate( $nt );
# Any text links to the old title must be reassigned to the redirect
- $dbw->updateArray( 'links', array( 'l_to' => $newid ), array( 'l_to' => $oldid ), $fname );
+ $dbw->update( 'links', array( 'l_to' => $newid ), array( 'l_to' => $oldid ), $fname );
LinkCache::linksccClearLinksTo( $oldid );
# Record the just-created redirect's linking to the page
- $dbw->insertArray( 'links', array( 'l_from' => $newid, 'l_to' => $oldid ), $fname );
+ $dbw->insert( 'links', array( 'l_from' => $newid, 'l_to' => $oldid ), $fname );
# Non-existent target may have had broken links to it; these must
# now be removed and made into good links.
# Is it a redirect?
$id = $nt->getArticleID();
- $obj = $dbw->getArray( 'cur', array( 'cur_is_redirect','cur_text' ),
+ $obj = $dbw->selectRow( 'cur', array( 'cur_is_redirect','cur_text' ),
array( 'cur_id' => $id ), $fname, 'FOR UPDATE' );
if ( !$obj || 0 == $obj->cur_is_redirect ) {
}
# Does the article have a history?
- $row = $dbw->getArray( 'old', array( 'old_id' ),
+ $row = $dbw->selectRow( 'old', array( 'old_id' ),
array(
'old_namespace' => $nt->getNamespace(),
'old_title' => $nt->getDBkey()
$won = wfInvertTimestamp( $now );
$seqVal = $dbw->nextSequenceValue( 'cur_cur_id_seq' );
- $dbw->insertArray( 'cur', array(
+ $dbw->insert( 'cur', array(
'cur_id' => $seqVal,
'cur_namespace' => $this->getNamespace(),
'cur_title' => $this->getDBkey(),
# Link table
if ( $dest->getArticleID() ) {
- $dbw->insertArray( 'links',
+ $dbw->insert( 'links',
array(
'l_to' => $dest->getArticleID(),
'l_from' => $newid
), $fname
);
} else {
- $dbw->insertArray( 'brokenlinks',
+ $dbw->insert( 'brokenlinks',
array(
'bl_to' => $dest->getPrefixedDBkey(),
'bl_from' => $newid
# Extract the intermap from meta
$dbr =& wfGetDB( DB_WRITE );
- $row = $dbr->getArray( "metawiki.cur", array( "cur_text" ),
+ $row = $dbr->selectRow( "metawiki.cur", array( "cur_text" ),
array( "cur_namespace" => 0, "cur_title" => "Interwiki_map" ) );
if ( !$row ) {
$md5_sql = pack("H32", $md5);
$mathTable = $dbr->tableName( 'math' );
- $rpage = $dbr->getArray( 'math', array('math_outputhash','math_html_conservativeness','math_html','math_mathml'),
+ $rpage = $dbr->selectRow( 'math', array('math_outputhash','math_html_conservativeness','math_html','math_mathml'),
array( 'math_inputhash' => $md5_sql ) );
if ( $rpage === false )
# Someone may have inserted the same hash since the SELECT, but that's no big deal, just ignore errors
$dbw =& wfGetDB( DB_MASTER );
- $dbw->insertArray( 'math',
+ $dbw->insert( 'math',
array(
'math_inputhash' => $md5_sql,
'math_outputhash' => $outmd5_sql,
// we don't really care if it fails
} else {
- $rpage = $dbr->fetchObject ( $res );
$outmd5 = unpack ("H32md5", $rpage->math_outputhash);
$outmd5 = $outmd5 ['md5'];
$outhtml = $rpage->math_html;