MediaWiki  REL1_21
DatabaseMysql Class Reference

Database abstraction object for mySQL Inherit all methods and properties of Database::Database() More...

Inheritance diagram for DatabaseMysql:
Collaboration diagram for DatabaseMysql:

List of all members.

Public Member Functions

 addIdentifierQuotes ($s)
 MySQL uses `backticks` for identifier quoting instead of the sql standard "double quotes".
 affectedRows ()
 dataSeek ($res, $row)
 deleteJoin ($delTable, $joinTable, $delVar, $joinVar, $conds, $fname= 'DatabaseBase::deleteJoin')
 DELETE where the condition is a join.
 dropTable ($tableName, $fName= 'DatabaseMysql::dropTable')
 duplicateTableStructure ($oldName, $newName, $temporary=false, $fname= 'DatabaseMysql::duplicateTableStructure')
 estimateRowCount ($table, $vars= '*', $conds= '', $fname= 'DatabaseMysql::estimateRowCount', $options=array())
 Estimate rows in dataset Returns estimated count, based on EXPLAIN output Takes same arguments as Database::select()
 fetchObject ($res)
 fetchRow ($res)
 fieldInfo ($table, $field)
 fieldName ($res, $n)
 freeResult ($res)
 getLag ()
 Returns slave lag.
 getLagFromProcesslist ()
 getLagFromSlaveStatus ()
 getMasterPos ()
 Get the position of the master from SHOW MASTER STATUS.
 getMysqlStatus ($which="%")
 Get status information from SHOW STATUS in an associative array.
 getSearchEngine ()
 Get search engine class.
 getServerUptime ()
 Determines how long the server has been up.
 getServerVersion ()
 getSlavePos ()
 Get the position of the master from SHOW SLAVE STATUS.
 getType ()
 indexInfo ($table, $index, $fname= 'DatabaseMysql::indexInfo')
 Get information about an index into an object Returns false if the index does not exist.
 insertId ()
 isQuotedIdentifier ($name)
 lastErrno ()
 lastError ()
 listTables ($prefix=null, $fname= 'DatabaseMysql::listTables')
 List all tables on the database.
 lock ($lockName, $method, $timeout=5)
 lockIsFree ($lockName, $method)
 Check to see if a named lock is available.
 lockTables ($read, $write, $method, $lowPriority=true)
 lowPriorityOption ()
 masterPosWait (DBMasterPos $pos, $timeout)
 Wait for the slave to catch up to a given master position.
 numFields ($res)
 numRows ($res)
 open ($server, $user, $password, $dbName)
 ping ()
 replace ($table, $uniqueIndexes, $rows, $fname= 'DatabaseMysql::replace')
 selectDB ($db)
 setBigSelects ($value=true)
 setSessionOptions (array $options)
 streamStatementEnd (&$sql, &$newLine)
 Called by sourceStream() to check if we've reached a statement end.
 strencode ($s)
 unlock ($lockName, $method)
 FROM MYSQL DOCS: http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_release-lock.
 unlockTables ($method)
 useIndexClause ($index)
 wasDeadlock ()
 Determines if the last failure was due to a deadlock.
 wasErrorReissuable ()
 Determines if the last query error was something that should be dealt with by pinging the connection and reissuing the query.
 wasLockTimeout ()
 Determines if the last failure was due to a lock timeout.
 wasReadOnlyError ()
 Determines if the last failure was due to the database being read-only.

Static Public Member Functions

static getSoftwareLink ()

Protected Member Functions

 closeConnection ()
 doQuery ($sql)
 getDefaultSchemaVars ()

Detailed Description

Database abstraction object for mySQL Inherit all methods and properties of Database::Database()

See also:
Database

Definition at line 31 of file DatabaseMysql.php.


Member Function Documentation

MySQL uses `backticks` for identifier quoting instead of the sql standard "double quotes".

Parameters:
$sstring
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 468 of file DatabaseMysql.php.

References $s, and strencode().

Referenced by duplicateTableStructure().

Returns:
int

Implements DatabaseType.

Definition at line 339 of file DatabaseMysql.php.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 174 of file DatabaseMysql.php.

DatabaseMysql::dataSeek ( res,
row 
)
Parameters:
$resResultWrapper
$row
Returns:
bool

Implements DatabaseType.

Definition at line 297 of file DatabaseMysql.php.

References $res.

DatabaseMysql::deleteJoin ( delTable,
joinTable,
delVar,
joinVar,
conds,
fname = 'DatabaseBase::deleteJoin' 
)

DELETE where the condition is a join.

MySql uses multi-table deletes.

Parameters:
$delTablestring
$joinTablestring
$delVarstring
$joinVarstring
$condsarray|string
bool | string$fnamebool
Exceptions:
DBUnexpectedError
Returns:
bool|ResultWrapper

Reimplemented from DatabaseBase.

Definition at line 817 of file DatabaseMysql.php.

References $fname, DatabaseBase\makeList(), DatabaseBase\query(), and DatabaseBase\tableName().

DatabaseMysql::doQuery ( sql) [protected]
Parameters:
$sqlstring
Returns:
resource

Reimplemented from DatabaseBase.

Definition at line 44 of file DatabaseMysql.php.

References $ret, and DatabaseBase\bufferResults().

Referenced by masterPosWait().

DatabaseMysql::dropTable ( tableName,
fName = 'DatabaseMysql::dropTable' 
)
Parameters:
$tableName
$fNamestring
Returns:
bool|ResultWrapper

Reimplemented from DatabaseBase.

Definition at line 924 of file DatabaseMysql.php.

References DatabaseBase\query(), DatabaseBase\tableExists(), and DatabaseBase\tableName().

DatabaseMysql::duplicateTableStructure ( oldName,
newName,
temporary = false,
fname = 'DatabaseMysql::duplicateTableStructure' 
)
Parameters:
$oldName
$newName
$temporarybool
$fnamestring

Reimplemented from DatabaseBase.

Definition at line 887 of file DatabaseMysql.php.

References $fname, $query, addIdentifierQuotes(), and DatabaseBase\query().

DatabaseMysql::estimateRowCount ( table,
vars = '*',
conds = '',
fname = 'DatabaseMysql::estimateRowCount',
options = array() 
)

Estimate rows in dataset Returns estimated count, based on EXPLAIN output Takes same arguments as Database::select()

Parameters:
$tablestring|array
$varsstring|array
$condsstring|array
$fnamestring
$optionsstring|array
Returns:
int

Reimplemented from DatabaseBase.

Definition at line 366 of file DatabaseMysql.php.

References $fname, $options, $res, $vars, as, numRows(), and DatabaseBase\select().

Parameters:
$resResultWrapper
Returns:
object|bool
Exceptions:
DBUnexpectedError

Implements DatabaseType.

Definition at line 199 of file DatabaseMysql.php.

References $res, lastErrno(), lastError(), wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by getMasterPos(), getSlavePos(), lock(), lockIsFree(), and unlock().

Parameters:
$resResultWrapper
Returns:
array|bool
Exceptions:
DBUnexpectedError

Implements DatabaseType.

Definition at line 223 of file DatabaseMysql.php.

References $res, lastErrno(), lastError(), wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by masterPosWait().

DatabaseMysql::fieldInfo ( table,
field 
)
Parameters:
$tablestring
$fieldstring
Returns:
bool|MySQLField

Implements DatabaseType.

Definition at line 388 of file DatabaseMysql.php.

References $n, $res, DatabaseBase\query(), and DatabaseBase\tableName().

DatabaseMysql::fieldName ( res,
n 
)
Parameters:
$resResultWrapper
$nstring
Returns:
string

Implements DatabaseType.

Definition at line 278 of file DatabaseMysql.php.

References $n, and $res.

Parameters:
$resResultWrapper
Exceptions:
DBUnexpectedError

Reimplemented from DatabaseBase.

Definition at line 182 of file DatabaseMysql.php.

References $ok, $res, wfRestoreWarnings(), and wfSuppressWarnings().

Returns:
array

Reimplemented from DatabaseBase.

Definition at line 934 of file DatabaseMysql.php.

References $vars.

Returns slave lag.

This will do a SHOW SLAVE STATUS

Returns:
int

Reimplemented from DatabaseBase.

Definition at line 503 of file DatabaseMysql.php.

References getLagFromSlaveStatus(), and wfDebug().

Deprecated:
in 1.19, use getLagFromSlaveStatus
Returns:
bool|int

Definition at line 536 of file DatabaseMysql.php.

References $res, as, DatabaseBase\query(), and wfDeprecated().

Returns:
bool|int

Definition at line 515 of file DatabaseMysql.php.

References $res, and DatabaseBase\query().

Referenced by getLag().

Get the position of the master from SHOW MASTER STATUS.

Returns:
MySQLMasterPos|bool

Reimplemented from DatabaseBase.

Definition at line 633 of file DatabaseMysql.php.

References $res, fetchObject(), and DatabaseBase\query().

DatabaseMysql::getMysqlStatus ( which = "%")

Get status information from SHOW STATUS in an associative array.

Parameters:
$whichstring
Returns:
array

Definition at line 947 of file DatabaseMysql.php.

References $res, array(), as, and DatabaseBase\query().

Referenced by getServerUptime().

Get search engine class.

All subclasses of this need to implement this if they wish to use searching.

Returns:
String

Reimplemented from DatabaseBase.

Definition at line 783 of file DatabaseMysql.php.

Determines how long the server has been up.

Returns:
int

Reimplemented from DatabaseBase.

Definition at line 838 of file DatabaseMysql.php.

References $vars, and getMysqlStatus().

Returns:
string

Implements DatabaseType.

Definition at line 651 of file DatabaseMysql.php.

Get the position of the master from SHOW SLAVE STATUS.

Returns:
MySQLMasterPos|bool

Reimplemented from DatabaseBase.

Definition at line 612 of file DatabaseMysql.php.

References $res, fetchObject(), and DatabaseBase\query().

static DatabaseMysql::getSoftwareLink ( ) [static]
Returns:
string

Implements DatabaseType.

Definition at line 673 of file DatabaseMysql.php.

Returns:
string

Implements DatabaseType.

Definition at line 36 of file DatabaseMysql.php.

DatabaseMysql::indexInfo ( table,
index,
fname = 'DatabaseMysql::indexInfo' 
)

Get information about an index into an object Returns false if the index does not exist.

Parameters:
$tablestring
$indexstring
$fnamestring
Returns:
bool|array|null False or null on failure

Implements DatabaseType.

Definition at line 413 of file DatabaseMysql.php.

References $fname, $res, $result, array(), as, empty, DatabaseBase\indexName(), DatabaseBase\query(), and DatabaseBase\tableName().

Returns:
int

Implements DatabaseType.

Definition at line 288 of file DatabaseMysql.php.

Parameters:
$namestring
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 476 of file DatabaseMysql.php.

References $name.

Returns:
string

Implements DatabaseType.

Definition at line 318 of file DatabaseMysql.php.

References $error, wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by fetchObject(), fetchRow(), open(), and wasReadOnlyError().

DatabaseMysql::listTables ( prefix = null,
fname = 'DatabaseMysql::listTables' 
)

List all tables on the database.

Parameters:
string$prefixOnly show tables with this prefix, e.g. mw_
string$fnamecalling function name
Returns:
array

Reimplemented from DatabaseBase.

Definition at line 902 of file DatabaseMysql.php.

References $fname, $result, $vars, array(), as, and DatabaseBase\query().

DatabaseMysql::lock ( lockName,
method,
timeout = 5 
)
Parameters:
$lockNamestring
$methodstring
$timeoutint
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 718 of file DatabaseMysql.php.

References $result, DatabaseBase\addQuotes(), fetchObject(), DatabaseBase\query(), and wfDebug().

DatabaseMysql::lockIsFree ( lockName,
method 
)

Check to see if a named lock is available.

This is non-blocking.

Parameters:
string$lockNamename of lock to poll
string$methodname of method calling us
Returns:
Boolean
Since:
1.20

Reimplemented from DatabaseBase.

Definition at line 705 of file DatabaseMysql.php.

References $result, DatabaseBase\addQuotes(), fetchObject(), and DatabaseBase\query().

DatabaseMysql::lockTables ( read,
write,
method,
lowPriority = true 
)
Parameters:
$readarray
$writearray
$methodstring
$lowPrioritybool
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 751 of file DatabaseMysql.php.

References array(), as, DatabaseBase\query(), and DatabaseBase\tableName().

Returns:
string

Reimplemented from DatabaseBase.

Definition at line 666 of file DatabaseMysql.php.

DatabaseMysql::masterPosWait ( DBMasterPos pos,
timeout 
)

Wait for the slave to catch up to a given master position.

Parameters:
$posDBMasterPos object
$timeoutInteger: the maximum number of seconds to wait for synchronisation
Returns:
bool|string

Reimplemented from DatabaseBase.

Definition at line 578 of file DatabaseMysql.php.

References $fname, $res, DatabaseBase\addQuotes(), DatabaseBase\commit(), doQuery(), fetchRow(), wfProfileIn(), and wfProfileOut().

Parameters:
$resResultWrapper
Returns:
int

Implements DatabaseType.

Definition at line 266 of file DatabaseMysql.php.

References $res.

Exceptions:
DBUnexpectedError
Parameters:
$resResultWrapper
Returns:
int

Implements DatabaseType.

Definition at line 247 of file DatabaseMysql.php.

References $n, $res, wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by estimateRowCount().

DatabaseMysql::open ( server,
user,
password,
dbName 
)
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 483 of file DatabaseMysql.php.

References open().

Referenced by strencode().

DatabaseMysql::replace ( table,
uniqueIndexes,
rows,
fname = 'DatabaseMysql::replace' 
)
Parameters:
$tablestring
$uniqueIndexes
$rowsarray
$fnamestring
Returns:
ResultWrapper

Reimplemented from DatabaseBase.

Definition at line 350 of file DatabaseMysql.php.

References $fname, and DatabaseBase\nativeReplace().

Parameters:
$db
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 441 of file DatabaseMysql.php.

Parameters:
bool$value
Returns:
mixed

Reimplemented from DatabaseBase.

Definition at line 791 of file DatabaseMysql.php.

References $value, DatabaseBase\query(), and DatabaseBase\selectField().

Parameters:
$optionsarray

Reimplemented from DatabaseBase.

Definition at line 680 of file DatabaseMysql.php.

References DatabaseBase\query().

DatabaseMysql::streamStatementEnd ( &$  sql,
&$  newLine 
)

Called by sourceStream() to check if we've reached a statement end.

Parameters:
string$sqlSQL assembled so far
string$newLineNew line about to be added to $sql
Returns:
Bool Whether $newLine contains end of the statement

Reimplemented from DatabaseBase.

Definition at line 688 of file DatabaseMysql.php.

Parameters:
$sstring
Returns:
string

Implements DatabaseType.

Definition at line 451 of file DatabaseMysql.php.

References $s, and ping().

Referenced by addIdentifierQuotes().

DatabaseMysql::unlock ( lockName,
method 
)

FROM MYSQL DOCS: http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_release-lock.

Parameters:
$lockNamestring
$methodstring
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 737 of file DatabaseMysql.php.

References $result, DatabaseBase\addQuotes(), fetchObject(), and DatabaseBase\query().

Parameters:
$methodstring
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 772 of file DatabaseMysql.php.

References DatabaseBase\query().

Parameters:
$index
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 659 of file DatabaseMysql.php.

References DatabaseBase\indexName().

Determines if the last failure was due to a deadlock.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 848 of file DatabaseMysql.php.

References lastErrno().

Determines if the last query error was something that should be dealt with by pinging the connection and reissuing the query.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 867 of file DatabaseMysql.php.

References lastErrno().

Determines if the last failure was due to a lock timeout.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 857 of file DatabaseMysql.php.

References lastErrno().

Determines if the last failure was due to the database being read-only.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 876 of file DatabaseMysql.php.

References false, lastErrno(), and lastError().


The documentation for this class was generated from the following file: