return 'mysql';
}
+ /**
+ * @param $sql
+ * @return resource
+ */
protected function doQuery( $sql ) {
if( $this->bufferResults() ) {
$ret = mysql_query( $sql, $this->mConn );
return $ret;
}
+ /**
+ * @param $server
+ * @param $user
+ * @param $password
+ * @param $dbName
+ * @return bool
+ * @throws DBConnectionError
+ */
function open( $server, $user, $password, $dbName ) {
global $wgAllDBsAreLocalhost;
wfProfileIn( __METHOD__ );
}
}
+ /**
+ * @param $res
+ * @throws DBUnexpectedError
+ */
function freeResult( $res ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
}
}
+ /**
+ * @param $res
+ * @return object|stdClass
+ * @throws DBUnexpectedError
+ */
function fetchObject( $res ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
return $row;
}
+ /**
+ * @param $res
+ * @return array
+ * @throws DBUnexpectedError
+ */
function fetchRow( $res ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
return mysql_insert_id( $this->mConn );
}
+ /**
+ * @param $res
+ * @param $row
+ * @return bool
+ */
function dataSeek( $res, $row ) {
if ( $res instanceof ResultWrapper ) {
$res = $res->result;
return mysql_data_seek( $res, $row );
}
+ /**
+ * @return int
+ */
function lastErrno() {
if ( $this->mConn ) {
return mysql_errno( $this->mConn );
}
}
+ /**
+ * @return string
+ */
function lastError() {
if ( $this->mConn ) {
# Even if it's non-zero, it can still be invalid
return mysql_affected_rows( $this->mConn );
}
+ /**
+ * @param $table
+ * @param $uniqueIndexes
+ * @param $rows
+ * @param $fname string
+ * @return ResultWrapper
+ */
function replace( $table, $uniqueIndexes, $rows, $fname = 'DatabaseMysql::replace' ) {
return $this->nativeReplace( $table, $rows, $fname );
}
* Returns estimated count, based on EXPLAIN output
* Takes same arguments as Database::select()
*
+ * @param $table string|array
+ * @param $vars string|array
+ * @param $conds string|array
+ * @param $fname string
+ * @param $options string|array
* @return int
*/
public function estimateRowCount( $table, $vars='*', $conds='', $fname = 'DatabaseMysql::estimateRowCount', $options = array() ) {
* Get information about an index into an object
* Returns false if the index does not exist
*
+ * @param $table
+ * @param $index
+ * @param $fname string
* @return false|array
*/
function indexInfo( $table, $index, $fname = 'DatabaseMysql::indexInfo' ) {
/**
* Returns slave lag.
*
- * On MySQL 4.1.9 and later, this will do a SHOW SLAVE STATUS
+ * This will do a SHOW SLAVE STATUS
*
* @return int
*/
*
* @param $pos DBMasterPos object
* @param $timeout Integer: the maximum number of seconds to wait for synchronisation
+ * @return bool|string
*/
function masterPosWait( DBMasterPos $pos, $timeout ) {
$fname = 'DatabaseBase::masterPosWait';
return '[http://www.mysql.com/ MySQL]';
}
+ /**
+ * @return bool
+ */
function standardSelectDistinct() {
return false;
}
- public function setTimeout( $timeout ) {
- $this->query( "SET net_read_timeout=$timeout" );
- $this->query( "SET net_write_timeout=$timeout" );
+ /**
+ * @param $options array
+ */
+ public function setSessionOptions( array $options ) {
+ if ( isset( $options['connTimeout'] ) ) {
+ $timeout = (int)$options['connTimeout'];
+ $this->query( "SET net_read_timeout=$timeout" );
+ $this->query( "SET net_write_timeout=$timeout" );
+ }
}
+ /**
+ * @param $lockName
+ * @param $method
+ * @param $timeout int
+ * @return bool
+ */
public function lock( $lockName, $method, $timeout = 5 ) {
$lockName = $this->addQuotes( $lockName );
$result = $this->query( "SELECT GET_LOCK($lockName, $timeout) AS lockstatus", $method );
/**
* FROM MYSQL DOCS: http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_release-lock
+ * @param $lockName
+ * @param $method string
+ * @return
*/
public function unlock( $lockName, $method ) {
$lockName = $this->addQuotes( $lockName );
return $row->lockstatus;
}
+ /**
+ * @param $read
+ * @param $write
+ * @param $method
+ * @param $lowPriority bool
+ */
public function lockTables( $read, $write, $method, $lowPriority = true ) {
$items = array();
$this->query( $sql, $method );
}
+ /**
+ * @param $method string
+ */
public function unlockTables( $method ) {
$this->query( "UNLOCK TABLES", $method );
}
return 'SearchMySQL';
}
+ /**
+ * @param bool $value
+ * @return mixed
+ */
public function setBigSelects( $value = true ) {
if ( $value === 'default' ) {
if ( $this->mDefaultBigSelects === null ) {
/**
* DELETE where the condition is a join. MySql uses multi-table deletes.
+ * @param $delTable
+ * @param $joinTable
+ * @param $delVar
+ * @param $joinVar
+ * @param $conds array|string
+ * @param $fname bool
+ * @return bool|\ResultWrapper
*/
function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname = 'DatabaseBase::deleteJoin' ) {
if ( !$conds ) {
return $this->query( $sql, $fname );
}
+ /**
+ * Determines how long the server has been up
+ *
+ * @return int
+ */
+ function getServerUptime() {
+ $vars = $this->getMysqlStatus( 'Uptime' );
+ return (int)$vars['Uptime'];
+ }
+
/**
* Determines if the last failure was due to a deadlock
*
return $this->lastErrno() == 1213;
}
+ /**
+ * Determines if the last failure was due to a lock timeout
+ *
+ * @return bool
+ */
+ function wasLockTimeout() {
+ return $this->lastErrno() == 1205;
+ }
+
/**
* Determines if the last query error was something that should be dealt
* with by pinging the connection and reissuing the query
( $this->lastErrno() == 1290 && strpos( $this->lastError(), '--read-only' ) !== false );
}
+ /**
+ * @param $oldName
+ * @param $newName
+ * @param $temporary bool
+ * @param $fname string
+ */
function duplicateTableStructure( $oldName, $newName, $temporary = false, $fname = 'DatabaseMysql::duplicateTableStructure' ) {
$tmp = $temporary ? 'TEMPORARY ' : '';
$newName = $this->addIdentifierQuotes( $newName );
*
* @param $prefix Only show tables with this prefix, e.g. mw_
* @param $fname String: calling function name
+ * @return array
*/
function listTables( $prefix = null, $fname = 'DatabaseMysql::listTables' ) {
$result = $this->query( "SHOW TABLES", $fname);
/**
* Get status information from SHOW STATUS in an associative array
*
+ * @param $which string
* @return array
*/
function getMysqlStatus( $which = "%" ) {
return $this->tableName;
}
+ /**
+ * @return string
+ */
function type() {
return $this->type;
}