MediaWiki  REL1_22
DatabaseMysqlBase Class Reference

Database abstraction object for MySQL. More...

Inheritance diagram for DatabaseMysqlBase:
Collaboration diagram for DatabaseMysqlBase:

List of all members.

Public Member Functions

 addIdentifierQuotes ($s)
 MySQL uses `backticks` for identifier quoting instead of the sql standard "double quotes".
 dataSeek ($res, $row)
 deleteJoin ($delTable, $joinTable, $delVar, $joinVar, $conds, $fname=__METHOD__)
 DELETE where the condition is a join.
 dropTable ($tableName, $fName=__METHOD__)
 duplicateTableStructure ($oldName, $newName, $temporary=false, $fname=__METHOD__)
 estimateRowCount ($table, $vars= '*', $conds= '', $fname=__METHOD__, $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.
 getSlavePos ()
 Get the position of the master from SHOW SLAVE STATUS.
 getSoftwareLink ()
 getType ()
 indexInfo ($table, $index, $fname=__METHOD__)
 Get information about an index into an object Returns false if the index does not exist.
 isQuotedIdentifier ($name)
 isView ($name, $prefix=null)
 Differentiates between a TABLE and a VIEW.
 lastError ()
 listTables ($prefix=null, $fname=__METHOD__)
 List all tables on the database.
 listViews ($prefix=null, $fname=__METHOD__)
 Lists VIEWs in 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=__METHOD__)
 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)
 upsert ($table, array $rows, array $uniqueIndexes, array $set, $fname=__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.

Protected Member Functions

 getDefaultSchemaVars ()
 mysqlConnect ($realServer)
 Open a connection to a MySQL server.
 mysqlDataSeek ($res, $row)
 Move internal result pointer.
 mysqlError ($conn=null)
 Returns the text of the error message from previous MySQL operation.
 mysqlFetchArray ($res)
 Fetch a result row as an associative and numeric array.
 mysqlFetchField ($res, $n)
 Get column information from a result.
 mysqlFetchObject ($res)
 Fetch a result row as an object.
 mysqlFieldName ($res, $n)
 Get the name of the specified field in a result.
 mysqlFreeResult ($res)
 Free result memory.
 mysqlNumFields ($res)
 Get number of fields in result.
 mysqlNumRows ($res)
 Get number of rows in result.
 mysqlPing ()
 Ping a server connection or reconnect if there is no connection.

Protected Attributes

MysqlMasterPos $lastKnownSlavePos
 *

Detailed Description

Database abstraction object for MySQL.

Defines methods independent on used MySQL extension.

Since:
1.22
See also:
Database

Definition at line 32 of file DatabaseMysqlBase.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 470 of file DatabaseMysqlBase.php.

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

Implements DatabaseType.

Definition at line 300 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::deleteJoin ( delTable,
joinTable,
delVar,
joinVar,
conds,
fname = __METHOD__ 
)

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 833 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::dropTable ( tableName,
fName = __METHOD__ 
)
Parameters:
$tableName
$fNamestring
Returns:
bool|ResultWrapper

Reimplemented from DatabaseBase.

Definition at line 971 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::duplicateTableStructure ( oldName,
newName,
temporary = false,
fname = __METHOD__ 
)
Parameters:
$oldName
$newName
$temporarybool
$fnamestring

Reimplemented from DatabaseBase.

Definition at line 934 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::estimateRowCount ( table,
vars = '*',
conds = '',
fname = __METHOD__,
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 368 of file DatabaseMysqlBase.php.

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

Implements DatabaseType.

Definition at line 168 of file DatabaseMysqlBase.php.

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

Implements DatabaseType.

Definition at line 200 of file DatabaseMysqlBase.php.

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

Implements DatabaseType.

Definition at line 390 of file DatabaseMysqlBase.php.

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

Implements DatabaseType.

Definition at line 279 of file DatabaseMysqlBase.php.

Parameters:
$resResultWrapper
Exceptions:
DBUnexpectedError

Reimplemented from DatabaseBase.

Definition at line 143 of file DatabaseMysqlBase.php.

Returns:
array

Reimplemented from DatabaseBase.

Definition at line 981 of file DatabaseMysqlBase.php.

Returns slave lag.

This will do a SHOW SLAVE STATUS

Returns:
int

Reimplemented from DatabaseBase.

Definition at line 514 of file DatabaseMysqlBase.php.

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

Definition at line 547 of file DatabaseMysqlBase.php.

Returns:
bool|int

Definition at line 526 of file DatabaseMysqlBase.php.

Get the position of the master from SHOW MASTER STATUS.

Returns:
MySQLMasterPos|bool

Reimplemented from DatabaseBase.

Definition at line 649 of file DatabaseMysqlBase.php.

Get status information from SHOW STATUS in an associative array.

Parameters:
$whichstring
Returns:
array

Definition at line 994 of file DatabaseMysqlBase.php.

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 799 of file DatabaseMysqlBase.php.

Determines how long the server has been up.

Returns:
int

Reimplemented from DatabaseBase.

Definition at line 885 of file DatabaseMysqlBase.php.

Get the position of the master from SHOW SLAVE STATUS.

Returns:
MySQLMasterPos|bool

Reimplemented from DatabaseBase.

Definition at line 628 of file DatabaseMysqlBase.php.

Returns:
string

Implements DatabaseType.

Definition at line 682 of file DatabaseMysqlBase.php.

Returns:
string

Implements DatabaseType.

Definition at line 38 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::indexInfo ( table,
index,
fname = __METHOD__ 
)

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 424 of file DatabaseMysqlBase.php.

Parameters:
$namestring
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 480 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::isView ( name,
prefix = null 
)

Differentiates between a TABLE and a VIEW.

Parameters:
$namestring: Name of the TABLE/VIEW to test
Returns:
bool
Since:
1.22

Definition at line 1050 of file DatabaseMysqlBase.php.

Returns:
string

Implements DatabaseType.

Definition at line 319 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::listTables ( prefix = null,
fname = __METHOD__ 
)

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 949 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::listViews ( prefix = null,
fname = __METHOD__ 
)

Lists VIEWs in the database.

Parameters:
string$prefixOnly show VIEWs with this prefix, eg. unit_test_, or $wgDBprefix. Default: null, would return all views.
string$fnameName of calling function
Returns:
array
Since:
1.22

Reimplemented from DatabaseBase.

Definition at line 1014 of file DatabaseMysqlBase.php.

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

Reimplemented from DatabaseBase.

Definition at line 734 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::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 721 of file DatabaseMysqlBase.php.

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

Reimplemented from DatabaseBase.

Definition at line 767 of file DatabaseMysqlBase.php.

Returns:
string

Reimplemented from DatabaseBase.

Definition at line 675 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::masterPosWait ( DBMasterPos pos,
timeout 
)

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

: return values for this and base class are rubbish

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

Reimplemented from DatabaseBase.

Definition at line 590 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::mysqlConnect ( realServer) [abstract, protected]

Open a connection to a MySQL server.

Parameters:
$realServerstring
Returns:
mixed Raw connection
Exceptions:
DBConnectionError

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

DatabaseMysqlBase::mysqlDataSeek ( res,
row 
) [abstract, protected]

Move internal result pointer.

Parameters:
$resRaw result
$rowint
Returns:
bool

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

DatabaseMysqlBase::mysqlError ( conn = null) [abstract, protected]

Returns the text of the error message from previous MySQL operation.

Parameters:
$connRaw connection
Returns:
string

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

DatabaseMysqlBase::mysqlFetchArray ( res) [abstract, protected]

Fetch a result row as an associative and numeric array.

Parameters:
$resRaw result
Returns:
array

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

DatabaseMysqlBase::mysqlFetchField ( res,
n 
) [abstract, protected]

Get column information from a result.

Parameters:
$resRaw result
$nint
Returns:
stdClass

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

DatabaseMysqlBase::mysqlFetchObject ( res) [abstract, protected]

Fetch a result row as an object.

Parameters:
$resRaw result
Returns:
stdClass

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

DatabaseMysqlBase::mysqlFieldName ( res,
n 
) [abstract, protected]

Get the name of the specified field in a result.

Parameters:
$resRaw result
$nint
Returns:
string

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

DatabaseMysqlBase::mysqlFreeResult ( res) [abstract, protected]

Free result memory.

Parameters:
$resRaw result
Returns:
bool

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

DatabaseMysqlBase::mysqlNumFields ( res) [abstract, protected]

Get number of fields in result.

Parameters:
$resRaw result
Returns:
int

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

DatabaseMysqlBase::mysqlNumRows ( res) [abstract, protected]

Get number of rows in result.

Parameters:
$resRaw result
Returns:
int

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

DatabaseMysqlBase::mysqlPing ( ) [abstract, protected]

Ping a server connection or reconnect if there is no connection.

Returns:
bool

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

Parameters:
$resResultWrapper
Returns:
int

Implements DatabaseType.

Definition at line 259 of file DatabaseMysqlBase.php.

Exceptions:
DBUnexpectedError
Parameters:
$resResultWrapper
Returns:
int

Implements DatabaseType.

Definition at line 232 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::open ( server,
user,
password,
dbName 
)
Parameters:
$serverstring
$userstring
$passwordstring
$dbNamestring
Returns:
bool
Exceptions:
DBConnectionError

Implements DatabaseType.

Definition at line 50 of file DatabaseMysqlBase.php.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 487 of file DatabaseMysqlBase.php.

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

Reimplemented from DatabaseBase.

Definition at line 352 of file DatabaseMysqlBase.php.

Parameters:
bool$value
Returns:
mixed

Reimplemented from DatabaseBase.

Definition at line 807 of file DatabaseMysqlBase.php.

Parameters:
$optionsarray

Reimplemented from DatabaseBase.

Definition at line 696 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::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 704 of file DatabaseMysqlBase.php.

Parameters:
$sstring
Returns:
string

Implements DatabaseType.

Definition at line 453 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::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 753 of file DatabaseMysqlBase.php.

Parameters:
$methodstring
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 788 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::upsert ( table,
array rows,
array uniqueIndexes,
array set,
fname = __METHOD__ 
)
Parameters:
string$table
array$rows
array$uniqueIndexes
array$set
string$fname
array$options
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 858 of file DatabaseMysqlBase.php.

Parameters:
$index
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 668 of file DatabaseMysqlBase.php.

Determines if the last failure was due to a deadlock.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 895 of file DatabaseMysqlBase.php.

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 914 of file DatabaseMysqlBase.php.

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

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 904 of file DatabaseMysqlBase.php.

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

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 923 of file DatabaseMysqlBase.php.


Member Data Documentation

MysqlMasterPos DatabaseMysqlBase::$lastKnownSlavePos [protected]

*

Definition at line 33 of file DatabaseMysqlBase.php.


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