MediaWiki  REL1_24
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)
 fieldType ($res, $n)
 mysql_field_type() wrapper
 freeResult ($res)
 getLag ()
 Returns slave lag.
 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)
 setFakeMaster ($enabled=true)
 Make this connection a fake master.
 setFakeSlaveLag ($lag)
 Set lag time in seconds for a fake slave.
 setSessionOptions (array $options)
 streamStatementEnd (&$sql, &$newLine)
 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

 connectInitCharset ()
 Set the character set information right after connection.
 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.
 mysqlFieldType ($res, $n)
 Get the type 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.
 mysqlSetCharset ($charset)
 Set the character set of the MySQL link.

Protected Attributes

MysqlMasterPos $lastKnownSlavePos
 *
 $mFakeMaster = false
null int $mFakeSlaveLag = null
 *

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:
string$s
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 546 of file DatabaseMysqlBase.php.

Set the character set information right after connection.

Returns:
bool

Reimplemented in DatabaseMysqli.

Definition at line 146 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::dataSeek ( res,
row 
)
Parameters:
ResultWrapper | resource$res
int$row
Returns:
bool

Implements DatabaseType.

Definition at line 370 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:
string$delTable
string$joinTable
string$delVar
string$joinVar
array | string$conds
bool | string$fname
Exceptions:
DBUnexpectedError
Returns:
bool|ResultWrapper

Reimplemented from DatabaseBase.

Definition at line 929 of file DatabaseMysqlBase.php.

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

Reimplemented from DatabaseBase.

Definition at line 1072 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::duplicateTableStructure ( oldName,
newName,
temporary = false,
fname = __METHOD__ 
)
Parameters:
string$oldName
string$newName
bool$temporary
string$fname
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 1034 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:
string | array$table
string | array$vars
string | array$conds
string$fname
string | array$options
Returns:
bool|int

Reimplemented from DatabaseBase.

Definition at line 440 of file DatabaseMysqlBase.php.

Parameters:
ResultWrapper | resource$res
Returns:
stdClass|bool
Exceptions:
DBUnexpectedError

Implements DatabaseType.

Definition at line 204 of file DatabaseMysqlBase.php.

Parameters:
ResultWrapper | resource$res
Returns:
array|bool
Exceptions:
DBUnexpectedError

Implements DatabaseType.

Definition at line 240 of file DatabaseMysqlBase.php.

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

Implements DatabaseType.

Definition at line 465 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::fieldName ( res,
n 
)
Parameters:
ResultWrapper | resource$res
int$n
Returns:
string

Implements DatabaseType.

Definition at line 325 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::fieldType ( res,
n 
)

mysql_field_type() wrapper

Parameters:
ResultWrapper | resource$res
int$n
Returns:
string

Definition at line 348 of file DatabaseMysqlBase.php.

Parameters:
ResultWrapper | resource$res
Exceptions:
DBUnexpectedError

Reimplemented from DatabaseBase.

Definition at line 179 of file DatabaseMysqlBase.php.

Returns:
array

Reimplemented from DatabaseBase.

Definition at line 1083 of file DatabaseMysqlBase.php.

Returns slave lag.

This will do a SHOW SLAVE STATUS

Returns:
int

Reimplemented from DatabaseBase.

Definition at line 609 of file DatabaseMysqlBase.php.

Returns:
bool|int

Definition at line 622 of file DatabaseMysqlBase.php.

Get the position of the master from SHOW MASTER STATUS.

Returns:
MySQLMasterPos|bool

Reimplemented from DatabaseBase.

Definition at line 730 of file DatabaseMysqlBase.php.

Get status information from SHOW STATUS in an associative array.

Parameters:
string$which
Returns:
array

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

Determines how long the server has been up.

Returns:
int

Reimplemented from DatabaseBase.

Definition at line 983 of file DatabaseMysqlBase.php.

Get the position of the master from SHOW SLAVE STATUS.

Returns:
MySQLMasterPos|bool

Reimplemented from DatabaseBase.

Definition at line 703 of file DatabaseMysqlBase.php.

Returns:
string

Implements DatabaseType.

Definition at line 763 of file DatabaseMysqlBase.php.

Returns:
string

Implements DatabaseType.

Definition at line 42 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:
string$table
string$index
string$fname
Returns:
bool|array|null False or null on failure

Implements DatabaseType.

Definition at line 500 of file DatabaseMysqlBase.php.

Parameters:
string$name
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 556 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::isView ( name,
prefix = null 
)

Differentiates between a TABLE and a VIEW.

Parameters:
string$nameName of the TABLE/VIEW to test
string$prefix
Returns:
bool
Since:
1.22

Definition at line 1159 of file DatabaseMysqlBase.php.

Returns:
string

Implements DatabaseType.

Definition at line 390 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 1050 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 1121 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::lock ( lockName,
method,
timeout = 5 
)
Parameters:
string$lockName
string$method
int$timeout
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 826 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:
bool
Since:
1.20

Reimplemented from DatabaseBase.

Definition at line 812 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::lockTables ( read,
write,
method,
lowPriority = true 
)
Parameters:
array$read
array$write
string$method
bool$lowPriority
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 862 of file DatabaseMysqlBase.php.

Returns:
string

Reimplemented from DatabaseBase.

Definition at line 756 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::masterPosWait ( DBMasterPos pos,
timeout 
)

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

Todo:
Return values for this and base class are rubbish
Parameters:
DBMasterPos | MySQLMasterPos$pos
int$timeoutThe maximum number of seconds to wait for synchronisation
Returns:
int Zero if the slave was past that position already, greater than zero if we waited for some period of time, less than zero if we timed out.

Reimplemented from DatabaseBase.

Definition at line 648 of file DatabaseMysqlBase.php.

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

Open a connection to a MySQL server.

Parameters:
string$realServer
Returns:
mixed Raw connection
Exceptions:
DBConnectionError

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

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

Move internal result pointer.

Parameters:
ResultWrapper | resource$res
int$row
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:
resource$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:
resource$resRaw result
Returns:
array

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

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

Get column information from a result.

Parameters:
resource$resRaw result
int$n
Returns:
stdClass

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

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

Fetch a result row as an object.

Parameters:
resource$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:
ResultWrapper | resource$res
int$n
Returns:
string

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

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

Get the type of the specified field in a result.

Parameters:
ResultWrapper | resource$res
int$n
Returns:
string

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

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

Free result memory.

Parameters:
resource$resRaw result
Returns:
bool

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

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

Get number of fields in result.

Parameters:
resource$resRaw result
Returns:
int

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

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

Get number of rows in result.

Parameters:
resource$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.

DatabaseMysqlBase::mysqlSetCharset ( charset) [abstract, protected]

Set the character set of the MySQL link.

Parameters:
string$charset
Returns:
bool

Reimplemented in DatabaseMysqli, DatabaseMysql, and FakeDatabaseMysqlBase.

Parameters:
ResultWrapper | resource$res
Returns:
int

Implements DatabaseType.

Definition at line 304 of file DatabaseMysqlBase.php.

Exceptions:
DBUnexpectedError
Parameters:
ResultWrapper | resource$res
Returns:
int

Implements DatabaseType.

Definition at line 276 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::open ( server,
user,
password,
dbName 
)
Parameters:
string$server
string$user
string$password
string$dbName
Exceptions:
Exception|DBConnectionError
Returns:
bool

Implements DatabaseType.

Definition at line 54 of file DatabaseMysqlBase.php.

Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 563 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::replace ( table,
uniqueIndexes,
rows,
fname = __METHOD__ 
)
Parameters:
string$table
array$uniqueIndexes
array$rows
string$fname
Returns:
ResultWrapper

Reimplemented from DatabaseBase.

Definition at line 424 of file DatabaseMysqlBase.php.

Parameters:
bool$value

Reimplemented from DatabaseBase.

Definition at line 903 of file DatabaseMysqlBase.php.

Make this connection a fake master.

Parameters:
bool$enabled

Reimplemented from DatabaseBase.

Definition at line 598 of file DatabaseMysqlBase.php.

Set lag time in seconds for a fake slave.

Parameters:
int$lag

Reimplemented from DatabaseBase.

Definition at line 589 of file DatabaseMysqlBase.php.

Parameters:
array$options

Reimplemented from DatabaseBase.

Definition at line 781 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::streamStatementEnd ( &$  sql,
&$  newLine 
)
Parameters:
string$sql
string$newLine
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 794 of file DatabaseMysqlBase.php.

Parameters:
string$s
Returns:
string

Implements DatabaseType.

Definition at line 529 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:
string$lockName
string$method
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 847 of file DatabaseMysqlBase.php.

Parameters:
string$method
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 884 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
Returns:
bool

Reimplemented from DatabaseBase.

Definition at line 953 of file DatabaseMysqlBase.php.

Parameters:
string$index
Returns:
string

Reimplemented from DatabaseBase.

Definition at line 749 of file DatabaseMysqlBase.php.

Determines if the last failure was due to a deadlock.

Returns:
bool

Reimplemented from DatabaseBase.

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

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

Returns:
bool

Reimplemented from DatabaseBase.

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


Member Data Documentation

MysqlMasterPos DatabaseMysqlBase::$lastKnownSlavePos [protected]

*

Definition at line 33 of file DatabaseMysqlBase.php.

DatabaseMysqlBase::$mFakeMaster = false [protected]

Definition at line 37 of file DatabaseMysqlBase.php.

null int DatabaseMysqlBase::$mFakeSlaveLag = null [protected]

*

Definition at line 35 of file DatabaseMysqlBase.php.


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