MediaWiki REL1_35
|
Helper class to handle automatically marking connections as reusable (via RAII pattern) as well handling deferring the actual network connection until the handle is used. More...
Public Member Functions | |
deadlockLoop (... $args) | |
Perform a deadlock-prone transaction. | |
dropTable ( $table, $fname=__METHOD__) | |
Delete a table. | |
duplicateTableStructure ( $oldName, $newName, $temporary=false, $fname=__METHOD__) | |
Creates a new table with structure copied from existing table. | |
fieldInfo ( $table, $field) | |
mysql_fetch_field() wrapper Returns false if the field doesn't exist | |
indexUnique ( $table, $index, $fname=__METHOD__) | |
Determines if a given index is unique. | |
listTables ( $prefix=null, $fname=__METHOD__) | |
List all tables on the database. | |
listViews ( $prefix=null, $fname=__METHOD__) | |
Lists all the VIEWs in the database. | |
lockTables (array $read, array $write, $method) | |
Lock specific tables. | |
sourceFile ( $filename, callable $lineCallback=null, callable $resultCallback=null, $fname=false, callable $inputCallback=null) | |
Read and execute SQL commands from a file. | |
sourceStream ( $fp, callable $lineCallback=null, callable $resultCallback=null, $fname=__METHOD__, callable $inputCallback=null) | |
Read and execute commands from an open file handle. | |
streamStatementEnd (&$sql, &$newLine) | |
Called by sourceStream() to check if we've reached a statement end. | |
tableLocksHaveTransactionScope () | |
Checks if table locks acquired by lockTables() are transaction-bound in their scope. | |
tableName ( $name, $format='quoted') | |
Format a table name ready for use in constructing an SQL query. | |
tableNames (... $tables) | |
Fetch a number of table names into an array This is handy when you need to construct SQL for joins. | |
tableNamesN (... $tables) | |
Fetch a number of table names into an zero-indexed numerical array This is handy when you need to construct SQL for joins. | |
textFieldSize ( $table, $field) | |
Returns the size of a text field, or -1 for "unlimited". | |
truncate ( $tables, $fname=__METHOD__) | |
Delete all data in a table(s) and reset any sequences owned by that table(s) | |
unlockTables ( $method) | |
Unlock all tables locked via lockTables() | |
Public Member Functions inherited from Wikimedia\Rdbms\DBConnRef | |
__call ( $name, array $arguments) | |
__construct (ILoadBalancer $lb, $conn, $role) | |
__destruct () | |
Clean up the connection when out of scope. | |
__toString () | |
Get a debugging string that mentions the database type, the ID of this instance, and the ID of any underlying connection resource or driver object if one is present. | |
addIdentifierQuotes ( $s) | |
Escape a SQL identifier (e.g. | |
addQuotes ( $s) | |
Escape and quote a raw value string for use in a SQL query. | |
affectedRows () | |
Get the number of rows affected by the last write query. | |
aggregateValue ( $valuedata, $valuename='value') | |
Return aggregated value alias. | |
anyChar () | |
Returns a token for buildLike() that denotes a '_' to be used in a LIKE query. | |
anyString () | |
Returns a token for buildLike() that denotes a '' to be used in a LIKE query. | |
assertNoOpenTransactions () | |
Assert that all explicit transactions or atomic sections have been closed. | |
begin ( $fname=__METHOD__, $mode=IDatabase::TRANSACTION_EXPLICIT) | |
Begin a transaction. | |
bitAnd ( $fieldLeft, $fieldRight) | |
bitNot ( $field) | |
bitOr ( $fieldLeft, $fieldRight) | |
buildConcat ( $stringList) | |
Build a concatenation list to feed into a SQL query. | |
buildGreatest ( $fields, $values) | |
Build a GREATEST function statement comparing columns/values. | |
buildGroupConcatField ( $delim, $table, $field, $conds='', $join_conds=[]) | |
Build a GROUP_CONCAT or equivalent statement for a query. | |
buildIntegerCast ( $field) | |
buildLeast ( $fields, $values) | |
Build a LEAST function statement comparing columns/values. | |
buildLike ( $param,... $params) | |
LIKE statement wrapper. | |
buildSelectSubquery ( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[]) | |
Equivalent to IDatabase::selectSQLText() except wraps the result in Subquery. | |
buildStringCast ( $field) | |
buildSubstring ( $input, $startPosition, $length=null) | |
cancelAtomic ( $fname=__METHOD__, AtomicSectionIdentifier $sectionId=null) | |
Cancel an atomic section of SQL statements. | |
clearFlag ( $flag, $remember=self::REMEMBER_NOTHING) | |
Clear a flag for this connection. | |
close ( $fname=__METHOD__, $owner=null) | |
Close the database connection. | |
commit ( $fname=__METHOD__, $flush=self::FLUSHING_ONE) | |
Commits a transaction previously started using begin() | |
conditional ( $cond, $trueVal, $falseVal) | |
Returns an SQL expression for a simple conditional. | |
databasesAreIndependent () | |
Returns true if DBs are assumed to be on potentially different servers. | |
dataSeek ( $res, $row) | |
Change the position of the cursor in a result object. | |
dbSchema ( $schema=null) | |
Get/set the db schema. | |
decodeBlob ( $b) | |
Some DBMSs return a special placeholder object representing blob fields in result objects. | |
decodeExpiry ( $expiry, $format=TS_MW) | |
Decode an expiry time into a DBMS independent format. | |
delete ( $table, $conds, $fname=__METHOD__) | |
Delete all rows in a table that match a condition. | |
deleteJoin ( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname=__METHOD__) | |
DELETE where the condition is a join. | |
doAtomicSection ( $fname, callable $callback, $cancelable=self::ATOMIC_NOT_CANCELABLE) | |
Perform an atomic section of reversable SQL statements from a callback. | |
encodeBlob ( $b) | |
Some DBMSs have a special format for inserting into blob fields, they don't allow simple quoted strings to be inserted. | |
encodeExpiry ( $expiry) | |
Encode an expiry time into the DBMS dependent format. | |
endAtomic ( $fname=__METHOD__) | |
Ends an atomic section of SQL statements. | |
estimateRowCount ( $tables, $vars=' *', $conds='', $fname=__METHOD__, $options=[], $join_conds=[]) | |
Estimate the number of rows in dataset. | |
explicitTrxActive () | |
fetchObject ( $res) | |
Fetch the next row from the given result object, in object form. | |
fetchRow ( $res) | |
Fetch the next row from the given result object, in associative array form. | |
fieldExists ( $table, $field, $fname=__METHOD__) | |
Determines whether a field exists in a table. | |
fieldName ( $res, $n) | |
Get a field name in a result object. | |
flushSnapshot ( $fname=__METHOD__, $flush=self::FLUSHING_ONE) | |
Commit any transaction but error out if writes or callbacks are pending. | |
freeResult ( $res) | |
Free a result object returned by query() or select() | |
getDBname () | |
Get the current DB name. | |
getDomainID () | |
Return the currently selected domain ID. | |
getFlag ( $flag) | |
Returns a boolean whether the flag $flag is set for this connection. | |
getInfinity () | |
Find out when 'infinity' is. | |
getLag () | |
Get the amount of replication lag for this database server. | |
getLBInfo ( $name=null) | |
Get properties passed down from the server info array of the load balancer. | |
getMasterPos () | |
Get the position of this master. | |
getProperty ( $name) | |
getReferenceRole () | |
getReplicaPos () | |
Get the replication position of this replica DB. | |
getScopedLockAndFlush ( $lockKey, $fname, $timeout) | |
Acquire a named lock, flush any transaction, and return an RAII style unlocker object. | |
getServer () | |
Get the server hostname or IP address. | |
getServerInfo () | |
Get a human-readable string describing the current software version. | |
getServerUptime () | |
Determines how long the server has been up. | |
getServerVersion () | |
A string describing the current software version, like from mysql_get_server_info() | |
getSessionLagStatus () | |
Get the replica DB lag when the current transaction started or a general lag estimate if not transaction is active. | |
getSoftwareLink () | |
Returns a wikitext style link to the DB's website (e.g. | |
getTopologyRole () | |
Get the replication topology role of this server. | |
getTopologyRootMaster () | |
Get the host (or address) of the root master server for the replication topology. | |
getType () | |
Get the type of the DBMS (e.g. | |
implicitOrderby () | |
Returns true if this database does an implicit order by when the column has an index For example: SELECT page_title FROM page LIMIT 1. | |
indexExists ( $table, $index, $fname=__METHOD__) | |
Determines whether an index exists. | |
insert ( $table, $rows, $fname=__METHOD__, $options=[]) | |
Insert the given row(s) into a table. | |
insertId () | |
Get the inserted value of an auto-increment row. | |
insertSelect ( $destTable, $srcTable, $varMap, $conds, $fname=__METHOD__, $insertOptions=[], $selectOptions=[], $selectJoinConds=[]) | |
INSERT SELECT wrapper. | |
isOpen () | |
isReadOnly () | |
lastDoneWrites () | |
Get the last time the connection may have been used for a write query. | |
lastErrno () | |
Get the last error number. | |
lastError () | |
Get a description of the last error. | |
lastQuery () | |
Get the last query that sent on account of IDatabase::query() | |
limitResult ( $sql, $limit, $offset=false) | |
Construct a LIMIT query with optional offset. | |
lock ( $lockName, $method, $timeout=5) | |
Acquire a named lock. | |
lockForUpdate ( $table, $conds='', $fname=__METHOD__, $options=[], $join_conds=[]) | |
Lock all rows meeting the given conditions/options FOR UPDATE. | |
lockIsFree ( $lockName, $method) | |
Check to see if a named lock is not locked by any thread (non-blocking) | |
makeList (array $a, $mode=self::LIST_COMMA) | |
Makes an encoded list of strings from an array. | |
makeWhereFrom2d ( $data, $baseKey, $subKey) | |
Build a partial where clause from a 2-d array such as used for LinkBatch. | |
masterPosWait (DBMasterPos $pos, $timeout) | |
Wait for the replica DB to catch up to a given master position. | |
maxListLen () | |
Return the maximum number of items allowed in a list, or 0 for unlimited. | |
namedLocksEnqueue () | |
Check to see if a named lock used by lock() use blocking queues. | |
newSelectQueryBuilder () | |
Create an empty SelectQueryBuilder which can be used to run queries against this connection. | |
nextSequenceValue ( $seqName) | |
Deprecated method, calls should be removed. | |
numFields ( $res) | |
Get the number of fields in a result object. | |
numRows ( $res) | |
Get the number of rows in a query result. | |
onAtomicSectionCancel (callable $callback, $fname=__METHOD__) | |
Run a callback when the atomic section is cancelled. | |
onTransactionCommitOrIdle (callable $callback, $fname=__METHOD__) | |
Run a callback as soon as there is no transaction pending. | |
onTransactionIdle (callable $callback, $fname=__METHOD__) | |
Alias for onTransactionCommitOrIdle() for backwards-compatibility. | |
onTransactionPreCommitOrIdle (callable $callback, $fname=__METHOD__) | |
Run a callback before the current transaction commits or now if there is none. | |
onTransactionResolution (callable $callback, $fname=__METHOD__) | |
Run a callback as soon as the current transaction commits or rolls back. | |
pendingWriteCallers () | |
Get the list of method names that did write queries for this transaction. | |
pendingWriteQueryDuration ( $type=self::ESTIMATE_TOTAL) | |
Get the time spend running write queries for this transaction. | |
pendingWriteRowsAffected () | |
Get the number of affected rows from pending write queries. | |
ping (&$rtt=null) | |
Ping the server and try to reconnect if it there is no connection. | |
preCommitCallbacksPending () | |
query ( $sql, $fname=__METHOD__, $flags=0) | |
Run an SQL query and return the result. | |
replace ( $table, $uniqueKeys, $rows, $fname=__METHOD__) | |
Insert row(s) into a table, deleting all conflicting rows beforehand. | |
restoreFlags ( $state=self::RESTORE_PRIOR) | |
Restore the flags to their prior state before the last setFlag/clearFlag call. | |
rollback ( $fname=__METHOD__, $flush=self::FLUSHING_ONE) | |
Rollback a transaction previously started using begin() | |
select ( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[]) | |
Execute a SELECT query constructed using the various parameters provided. | |
selectDB ( $db) | |
Change the current database. | |
selectDomain ( $domain) | |
Set the current domain (database, schema, and table prefix) | |
selectField ( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[]) | |
A SELECT wrapper which returns a single field from a single result row. | |
selectFieldValues ( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[]) | |
A SELECT wrapper which returns a list of single field values from result rows. | |
selectRow ( $table, $vars, $conds, $fname=__METHOD__, $options=[], $join_conds=[]) | |
Wrapper to IDatabase::select() that only fetches one row (via LIMIT) | |
selectRowCount ( $tables, $vars=' *', $conds='', $fname=__METHOD__, $options=[], $join_conds=[]) | |
Get the number of rows in dataset. | |
selectSQLText ( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[]) | |
Take the same arguments as IDatabase::select() and return the SQL it would use. | |
serverIsReadOnly () | |
setBigSelects ( $value=true) | |
Allow or deny "big selects" for this session only. | |
setFlag ( $flag, $remember=self::REMEMBER_NOTHING) | |
Set a flag for this connection. | |
setIndexAliases (array $aliases) | |
Convert certain index names to alternative names before querying the DB. | |
setLBInfo ( $nameOrArray, $value=null) | |
Set the entire array or a particular key of the managing load balancer info array. | |
setSchemaVars ( $vars) | |
Set schema variables to be used when streaming commands from SQL files or stdin. | |
setSessionOptions (array $options) | |
Override database's default behavior. | |
setTableAliases (array $aliases) | |
Make certain table names use their own database, schema, and table prefix when passed into SQL queries pre-escaped and without a qualified database name. | |
setTransactionListener ( $name, callable $callback=null) | |
Run a callback after each time any transaction commits or rolls back. | |
startAtomic ( $fname=__METHOD__, $cancelable=IDatabase::ATOMIC_NOT_CANCELABLE) | |
Begin an atomic section of SQL statements. | |
strreplace ( $orig, $old, $new) | |
Returns a SQL expression for simple string replacement (e.g. | |
tableExists ( $table, $fname=__METHOD__) | |
Query whether a given table exists. | |
tablePrefix ( $prefix=null) | |
Get/set the table prefix. | |
timestamp ( $ts=0) | |
Convert a timestamp in one of the formats accepted by ConvertibleTimestamp to the format used for inserting into timestamp fields in this DBMS. | |
timestampOrNull ( $ts=null) | |
Convert a timestamp in one of the formats accepted by ConvertibleTimestamp to the format used for inserting into timestamp fields in this DBMS. | |
trxLevel () | |
Gets the current transaction level. | |
trxTimestamp () | |
Get the UNIX timestamp of the time that the transaction was established. | |
unionConditionPermutations ( $table, $vars, array $permute_conds, $extra_conds='', $fname=__METHOD__, $options=[], $join_conds=[]) | |
Construct a UNION query for permutations of conditions. | |
unionQueries ( $sqls, $all) | |
Construct a UNION query. | |
unionSupportsOrderAndLimit () | |
Determine if the RDBMS supports ORDER BY and LIMIT for separate subqueries within UNION. | |
unlock ( $lockName, $method) | |
Release a lock. | |
update ( $table, $set, $conds, $fname=__METHOD__, $options=[]) | |
Update all rows in a table that match a given condition. | |
upsert ( $table, array $rows, $uniqueKeys, array $set, $fname=__METHOD__) | |
Upsert the given row(s) into a table. | |
wasConnectionLoss () | |
Determines if the last query error was due to a dropped connection. | |
wasDeadlock () | |
Determines if the last failure was due to a deadlock. | |
wasErrorReissuable () | |
Determines if the last query error was due to something outside of the query itself. | |
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. | |
writesOrCallbacksPending () | |
Whether there is a transaction open with either possible write queries or unresolved pre-commit/commit/resolution callbacks pending. | |
writesPending () | |
Public Member Functions inherited from Wikimedia\Rdbms\IDatabase | |
buildSubString ( $input, $startPosition, $length=null) | |
Build a SUBSTRING function. | |
Additional Inherited Members | |
Protected Member Functions inherited from Wikimedia\Rdbms\DBConnRef | |
assertRoleAllowsWrites () | |
Error out if the role is not DB_MASTER. | |
getDomainChangeException () | |
Helper class to handle automatically marking connections as reusable (via RAII pattern) as well handling deferring the actual network connection until the handle is used.
Definition at line 13 of file MaintainableDBConnRef.php.
Wikimedia\Rdbms\MaintainableDBConnRef::deadlockLoop | ( | $args | ) |
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.
Avoid using this method outside of Job or Maintenance classes.
Usage: $dbw->deadlockLoop( callback, ... );
Extra arguments are passed through to the specified callback function. This method requires that no transactions are already active to avoid causing premature commits or exceptions.
Returns whatever the callback function returned on its successful, iteration, or false on error, for example if the retry limit was reached.
mixed | ...$args |
DBUnexpectedError | |
Exception |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 62 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call(), and Wikimedia\Rdbms\DBConnRef\assertRoleAllowsWrites().
Wikimedia\Rdbms\MaintainableDBConnRef::dropTable | ( | $table, | |
$fname = __METHOD__ |
|||
) |
Delete a table.
string | $table | |
string | $fname |
DBError | If an error occurs |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 50 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call(), and Wikimedia\Rdbms\DBConnRef\assertRoleAllowsWrites().
Wikimedia\Rdbms\MaintainableDBConnRef::duplicateTableStructure | ( | $oldName, | |
$newName, | |||
$temporary = false , |
|||
$fname = __METHOD__ |
|||
) |
Creates a new table with structure copied from existing table.
Note that unlike most database abstraction functions, this function does not automatically append database prefix, because it works at a lower abstraction level. The table names passed to this function shall not be quoted (this function calls addIdentifierQuotes() when needed).
string | $oldName | Name of table whose structure should be copied |
string | $newName | Name of table to be created |
bool | $temporary | Whether the new table should be temporary |
string | $fname | Calling function name |
RuntimeException |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 80 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call(), and Wikimedia\Rdbms\DBConnRef\assertRoleAllowsWrites().
Wikimedia\Rdbms\MaintainableDBConnRef::fieldInfo | ( | $table, | |
$field | |||
) |
mysql_fetch_field() wrapper Returns false if the field doesn't exist
string | $table | Table name |
string | $field | Field name |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 112 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call().
Wikimedia\Rdbms\MaintainableDBConnRef::indexUnique | ( | $table, | |
$index, | |||
$fname = __METHOD__ |
|||
) |
Determines if a given index is unique.
string | $table | |
string | $index | |
string | $fname | Calling function name |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 104 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call().
Wikimedia\Rdbms\MaintainableDBConnRef::listTables | ( | $prefix = null , |
|
$fname = __METHOD__ |
|||
) |
List all tables on the database.
string | null | $prefix | Only show tables with this prefix, e.g. mw_ |
string | $fname | Calling function name |
DBError |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 108 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call().
Wikimedia\Rdbms\MaintainableDBConnRef::listViews | ( | $prefix = null , |
|
$fname = __METHOD__ |
|||
) |
Lists all the VIEWs in the database.
string | null | $prefix | Only show VIEWs with this prefix, eg. unit_test_ |
string | $fname | Name of calling function |
RuntimeException |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 68 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call().
Wikimedia\Rdbms\MaintainableDBConnRef::lockTables | ( | array | $read, |
array | $write, | ||
$method | |||
) |
Lock specific tables.
Any pending transaction should be resolved before calling this method, since: a) Doing so resets any REPEATABLE-READ snapshot of the data to a fresh one. b) Previous row and table locks from the transaction or session may be released by LOCK TABLES, which may be unsafe for the changes in such a transaction. c) The main use case of lockTables() is to avoid deadlocks and timeouts by locking entire tables in order to do long-running, batched, and lag-aware, updates. Batching and replication lag checks do not work when all the updates happen in a transaction.
Always get all relevant table locks up-front in one call, since LOCK TABLES might release any prior table locks on some RDBMes (e.g MySQL).
For compatibility, callers should check tableLocksHaveTransactionScope() before using this method. If locks are scoped specifically to transactions then caller must either:
If session scoped locks are not supported, then calling lockTables() will trigger startAtomic(), with unlockTables() triggering endAtomic(). This will automatically start a transaction if one is not already present and cause the locks to be released when the transaction finishes (normally during the unlockTables() call).
In any case, avoid using begin()/commit() in code that runs while such table locks are acquired, as that breaks in case when a transaction is needed. The startAtomic() and endAtomic() methods are safe, however, since they will join any existing transaction.
array | $read | Array of tables to lock for read access |
array | $write | Array of tables to lock for write access |
string | $method | Name of caller |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 92 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call(), and Wikimedia\Rdbms\DBConnRef\assertRoleAllowsWrites().
Wikimedia\Rdbms\MaintainableDBConnRef::sourceFile | ( | $filename, | |
callable | $lineCallback = null , |
||
callable | $resultCallback = null , |
||
$fname = false , |
|||
callable | $inputCallback = null |
||
) |
Read and execute SQL commands from a file.
Returns true on success, error string or exception on failure (depending on object's error ignore settings).
string | $filename | File name to open |
callable | null | $lineCallback | Optional function called before reading each line |
callable | null | $resultCallback | Optional function called for each MySQL result |
bool | string | $fname | Calling function name or false if name should be generated dynamically using $filename |
callable | null | $inputCallback | Optional function called for each complete line sent |
Exception |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 26 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call(), and Wikimedia\Rdbms\DBConnRef\assertRoleAllowsWrites().
Wikimedia\Rdbms\MaintainableDBConnRef::sourceStream | ( | $fp, | |
callable | $lineCallback = null , |
||
callable | $resultCallback = null , |
||
$fname = __METHOD__ , |
|||
callable | $inputCallback = null |
||
) |
Read and execute commands from an open file handle.
Returns true on success, error string or exception on failure (depending on object's error ignore settings).
resource | $fp | File handle |
callable | null | $lineCallback | Optional function called before reading each query |
callable | null | $resultCallback | Optional function called for each MySQL result |
string | $fname | Calling function name |
callable | null | $inputCallback | Optional function called for each complete query sent |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 38 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call(), and Wikimedia\Rdbms\DBConnRef\assertRoleAllowsWrites().
Wikimedia\Rdbms\MaintainableDBConnRef::streamStatementEnd | ( | & | $sql, |
& | $newLine | ||
) |
Called by sourceStream() to check if we've reached a statement end.
string | &$sql | SQL assembled so far |
string | &$newLine | New line about to be added to $sql |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 76 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call().
Wikimedia\Rdbms\MaintainableDBConnRef::tableLocksHaveTransactionScope | ( | ) |
Checks if table locks acquired by lockTables() are transaction-bound in their scope.
Transaction-bound table locks will be released when the current transaction terminates. Table locks that are not bound to a transaction are not effected by BEGIN/COMMIT/ROLLBACK and will last until either lockTables()/unlockTables() is called or the TCP connection to the database is closed.
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 88 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call().
Wikimedia\Rdbms\MaintainableDBConnRef::tableName | ( | $name, | |
$format = 'quoted' |
|||
) |
Format a table name ready for use in constructing an SQL query.
This does two important things: it quotes the table names to clean them up, and it adds a table prefix if only given a table name with no quotes.
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.
string | $name | Database table name |
string | $format | One of: quoted - Automatically pass the table name through addIdentifierQuotes() so that it can be used in a query. raw - Do not add identifier quotes to the table name |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 14 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call().
Wikimedia\Rdbms\MaintainableDBConnRef::tableNames | ( | $tables | ) |
Fetch a number of table names into an array This is handy when you need to construct SQL for joins.
Example: list( $user, $watchlist ) = $dbr->tableNames( 'user', 'watchlist' ) ); $sql = "SELECT wl_namespace, wl_title FROM $watchlist, $user WHERE wl_user=user_id AND wl_user=$nameWithQuotes";
string | ...$tables |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 18 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call().
Wikimedia\Rdbms\MaintainableDBConnRef::tableNamesN | ( | $tables | ) |
Fetch a number of table names into an zero-indexed numerical array This is handy when you need to construct SQL for joins.
Example: list( $user, $watchlist ) = $dbr->tableNamesN( 'user', 'watchlist' ); $sql = "SELECT wl_namespace,wl_title FROM $watchlist,$user WHERE wl_user=user_id AND wl_user=$nameWithQuotes";
string | ...$tables |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 22 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call().
Wikimedia\Rdbms\MaintainableDBConnRef::textFieldSize | ( | $table, | |
$field | |||
) |
Returns the size of a text field, or -1 for "unlimited".
string | $table | |
string | $field |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 72 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call().
Wikimedia\Rdbms\MaintainableDBConnRef::truncate | ( | $tables, | |
$fname = __METHOD__ |
|||
) |
Delete all data in a table(s) and reset any sequences owned by that table(s)
string | string[] | $tables | |
string | $fname |
DBError | If an error occurs |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 56 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call(), and Wikimedia\Rdbms\DBConnRef\assertRoleAllowsWrites().
Wikimedia\Rdbms\MaintainableDBConnRef::unlockTables | ( | $method | ) |
Unlock all tables locked via lockTables()
If table locks are scoped to transactions, then locks might not be released until the transaction ends, which could happen after this method is called.
string | $method | The caller |
Implements Wikimedia\Rdbms\IMaintainableDatabase.
Definition at line 98 of file MaintainableDBConnRef.php.
References Wikimedia\Rdbms\DBConnRef\__call(), and Wikimedia\Rdbms\DBConnRef\assertRoleAllowsWrites().