MediaWiki  master
Wikimedia\Rdbms\IMaintainableDatabase Interface Reference

Advanced database interface for IDatabase handles that include maintenance methods. More...

Inheritance diagram for Wikimedia\Rdbms\IMaintainableDatabase:
Collaboration diagram for Wikimedia\Rdbms\IMaintainableDatabase:

Public Member Functions

 deadlockLoop (... $args)
 Perform a deadlock-prone transaction. More...
 
 dropTable ( $table, $fname=__METHOD__)
 Delete a table. More...
 
 duplicateTableStructure ( $oldName, $newName, $temporary=false, $fname=__METHOD__)
 Creates a new table with structure copied from existing table. More...
 
 fieldInfo ( $table, $field)
 Get information about a field Returns false if the field doesn't exist. More...
 
 indexUnique ( $table, $index, $fname=__METHOD__)
 Determines if a given index is unique. More...
 
 listTables ( $prefix=null, $fname=__METHOD__)
 List all tables on the database. More...
 
 listViews ( $prefix=null, $fname=__METHOD__)
 Lists all the VIEWs in the database. More...
 
 sourceFile ( $filename, callable $lineCallback=null, callable $resultCallback=null, $fname=false, callable $inputCallback=null)
 Read and execute SQL commands from a file. More...
 
 sourceStream ( $fp, callable $lineCallback=null, callable $resultCallback=null, $fname=__METHOD__, callable $inputCallback=null)
 Read and execute commands from an open file handle. More...
 
 streamStatementEnd (&$sql, &$newLine)
 Called by sourceStream() to check if we've reached a statement end. More...
 
 tableName ( $name, $format='quoted')
 Format a table name ready for use in constructing an SQL query. More...
 
 tableNames (... $tables)
 Fetch a number of table names into an array This is handy when you need to construct SQL for joins. More...
 
 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. More...
 
 textFieldSize ( $table, $field)
 Returns the size of a text field, or -1 for "unlimited". More...
 
 truncate ( $tables, $fname=__METHOD__)
 Delete all data in a table(s) and reset any sequences owned by that table(s) More...
 
- Public Member Functions inherited from Wikimedia\Rdbms\IDatabase
 __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. More...
 
 affectedRows ()
 Get the number of rows affected by the last write query. More...
 
 begin ( $fname=__METHOD__, $mode=self::TRANSACTION_EXPLICIT)
 Begin a transaction. More...
 
 buildGroupConcatField ( $delim, $table, $field, $conds='', $join_conds=[])
 Build a GROUP_CONCAT or equivalent statement for a query. More...
 
 buildSelectSubquery ( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
 Equivalent to IDatabase::selectSQLText() except wraps the result in Subquery. More...
 
 cancelAtomic ( $fname=__METHOD__, AtomicSectionIdentifier $sectionId=null)
 Cancel an atomic section of SQL statements. More...
 
 clearFlag ( $flag, $remember=self::REMEMBER_NOTHING)
 Clear a flag for this connection. More...
 
 close ( $fname=__METHOD__)
 Close the database connection. More...
 
 commit ( $fname=__METHOD__, $flush=self::FLUSHING_ONE)
 Commits a transaction previously started using begin() More...
 
 databasesAreIndependent ()
 Returns true if DBs are assumed to be on potentially different servers. More...
 
 dbSchema ( $schema=null)
 Get/set the db schema. More...
 
 decodeBlob ( $b)
 Some DBMSs return a special placeholder object representing blob fields in result objects. More...
 
 delete ( $table, $conds, $fname=__METHOD__)
 Delete all rows in a table that match a condition. More...
 
 deleteJoin ( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname=__METHOD__)
 DELETE where the condition is a join. More...
 
 doAtomicSection ( $fname, callable $callback, $cancelable=self::ATOMIC_NOT_CANCELABLE)
 Perform an atomic section of reversible SQL statements from a callback. More...
 
 encodeBlob ( $b)
 Some DBMSs have a special format for inserting into blob fields, they don't allow simple quoted strings to be inserted. More...
 
 endAtomic ( $fname=__METHOD__)
 Ends an atomic section of SQL statements. More...
 
 estimateRowCount ( $tables, $var=' *', $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
 Estimate the number of rows in dataset. More...
 
 explicitTrxActive ()
 Check whether there is a transaction open at the specific request of a caller. More...
 
 fieldExists ( $table, $field, $fname=__METHOD__)
 Determines whether a field exists in a table. More...
 
 flushSession ( $fname=__METHOD__)
 Release important session-level state (named lock, table locks) as post-rollback cleanup. More...
 
 flushSnapshot ( $fname=__METHOD__, $flush=self::FLUSHING_ONE)
 Commit any transaction but error out if writes or callbacks are pending. More...
 
 getDBname ()
 Get the current database name; null if there isn't one. More...
 
 getDomainID ()
 Return the currently selected domain ID. More...
 
 getFlag ( $flag)
 Returns a boolean whether the flag $flag is set for this connection. More...
 
 getLag ()
 Get the amount of replication lag for this database server. More...
 
 getLBInfo ( $name=null)
 Get properties passed down from the server info array of the load balancer. More...
 
 getPrimaryPos ()
 Get the position of this primary DB. More...
 
 getReplicaPos ()
 Get the replication position of this replica DB. More...
 
 getScopedLockAndFlush ( $lockKey, $fname, $timeout)
 Acquire a named lock, flush any transaction, and return an RAII style unlocker object. More...
 
 getServer ()
 Get the hostname or IP address of the server. More...
 
 getServerInfo ()
 Get a human-readable string describing the current software version. More...
 
 getServerName ()
 Get the readable name for the server. More...
 
 getServerVersion ()
 A string describing the current software version, like from mysql_get_server_info() More...
 
 getSessionLagStatus ()
 Get the replica DB lag when the current transaction started or a general lag estimate if not transaction is active. More...
 
 getSoftwareLink ()
 Returns a wikitext style link to the DB's website (e.g. More...
 
 getTopologyBasedServerId ()
 Get a non-recycled ID that uniquely identifies this server within the replication topology. More...
 
 getTopologyRole ()
 Get the replication topology role of this server. More...
 
 getTopologyRootPrimary ()
 Get the readable name of the sole root primary DB server for the replication topology. More...
 
 getType ()
 Get the RDBMS type of the server (e.g. More...
 
 indexExists ( $table, $index, $fname=__METHOD__)
 Determines whether an index exists. More...
 
 insert ( $table, $rows, $fname=__METHOD__, $options=[])
 Insert row(s) into a table, in the provided order. More...
 
 insertId ()
 Get the inserted value of an auto-increment row. More...
 
 insertSelect ( $destTable, $srcTable, $varMap, $conds, $fname=__METHOD__, $insertOptions=[], $selectOptions=[], $selectJoinConds=[])
 INSERT SELECT wrapper. More...
 
 isOpen ()
 
 isReadOnly ()
 
 lastDoneWrites ()
 Get the last time the connection may have been used for a write query. More...
 
 lastErrno ()
 Get the RDBMS-specific error code from the last query statement. More...
 
 lastError ()
 Get the RDBMS-specific error description from the last query statement. More...
 
 lastQuery ()
 Get the last query that sent on account of IDatabase::query() More...
 
 lock ( $lockName, $method, $timeout=5, $flags=0)
 Acquire a named lock. More...
 
 lockForUpdate ( $table, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
 Lock all rows meeting the given conditions/options FOR UPDATE. More...
 
 lockIsFree ( $lockName, $method)
 Check to see if a named lock is not locked by any thread (non-blocking) More...
 
 namedLocksEnqueue ()
 Check to see if a named lock used by lock() use blocking queues. More...
 
 newSelectQueryBuilder ()
 Create an empty SelectQueryBuilder which can be used to run queries against this connection. More...
 
 nextSequenceValue ( $seqName)
 Deprecated method, calls should be removed. More...
 
 onAtomicSectionCancel (callable $callback, $fname=__METHOD__)
 Run a callback when the atomic section is cancelled. More...
 
 onTransactionCommitOrIdle (callable $callback, $fname=__METHOD__)
 Run a callback when the current transaction commits or now if there is none. More...
 
 onTransactionPreCommitOrIdle (callable $callback, $fname=__METHOD__)
 Run a callback before the current transaction commits or now if there is none. More...
 
 onTransactionResolution (callable $callback, $fname=__METHOD__)
 Run a callback when the current transaction commits or rolls back. More...
 
 pendingWriteCallers ()
 Get the list of method names that did write queries for this transaction. More...
 
 pendingWriteQueryDuration ( $type=self::ESTIMATE_TOTAL)
 Get the time spend running write queries for this transaction. More...
 
 ping (&$rtt=null)
 Ping the server and try to reconnect if it there is no connection. More...
 
 primaryPosWait (DBPrimaryPos $pos, $timeout)
 Wait for the replica DB to catch up to a given primary DB position. More...
 
 query ( $sql, $fname=__METHOD__, $flags=0)
 Run an SQL query statement and return the result. More...
 
 replace ( $table, $uniqueKeys, $rows, $fname=__METHOD__)
 Insert row(s) into a table, in the provided order, while deleting conflicting rows. More...
 
 restoreFlags ( $state=self::RESTORE_PRIOR)
 Restore the flags to their prior state before the last setFlag/clearFlag call. More...
 
 rollback ( $fname=__METHOD__, $flush=self::FLUSHING_ONE)
 Rollback a transaction previously started using begin() More...
 
 select ( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
 Execute a SELECT query constructed using the various parameters provided. More...
 
 selectDB ( $db)
 Change the current database. More...
 
 selectDomain ( $domain)
 Set the current domain (database, schema, and table prefix) More...
 
 selectField ( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
 A SELECT wrapper which returns a single field from a single result row. More...
 
 selectFieldValues ( $table, $var, $cond='', $fname=__METHOD__, $options=[], $join_conds=[])
 A SELECT wrapper which returns a list of single field values from result rows. More...
 
 selectRow ( $table, $vars, $conds, $fname=__METHOD__, $options=[], $join_conds=[])
 Wrapper to IDatabase::select() that only fetches one row (via LIMIT) More...
 
 selectRowCount ( $tables, $var=' *', $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
 Get the number of rows in dataset. More...
 
 selectSQLText ( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[])
 Take the same arguments as IDatabase::select() and return the SQL it would use. More...
 
 serverIsReadOnly ()
 
 setBigSelects ( $value=true)
 Allow or deny "big selects" for this session only. More...
 
 setFlag ( $flag, $remember=self::REMEMBER_NOTHING)
 Set a flag for this connection. More...
 
 setIndexAliases (array $aliases)
 Convert certain index names to alternative names before querying the DB. More...
 
 setLBInfo ( $nameOrArray, $value=null)
 Set the entire array or a particular key of the managing load balancer info array. More...
 
 setSchemaVars ( $vars)
 Set schema variables to be used when streaming commands from SQL files or stdin. More...
 
 setSessionOptions (array $options)
 Override database's default behavior. More...
 
 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. More...
 
 setTransactionListener ( $name, callable $callback=null)
 Run a callback after each time any transaction commits or rolls back. More...
 
 startAtomic ( $fname=__METHOD__, $cancelable=self::ATOMIC_NOT_CANCELABLE)
 Begin an atomic section of SQL statements. More...
 
 tableExists ( $table, $fname=__METHOD__)
 Query whether a given table exists. More...
 
 tablePrefix ( $prefix=null)
 Get/set the table prefix. More...
 
 trxLevel ()
 Gets the current transaction level. More...
 
 trxTimestamp ()
 Get the UNIX timestamp of the time that the transaction was established. More...
 
 unionConditionPermutations ( $table, $vars, array $permute_conds, $extra_conds='', $fname=__METHOD__, $options=[], $join_conds=[])
 Construct a UNION query for permutations of conditions. More...
 
 unlock ( $lockName, $method)
 Release a lock. More...
 
 update ( $table, $set, $conds, $fname=__METHOD__, $options=[])
 Update all rows in a table that match a given condition. More...
 
 upsert ( $table, array $rows, $uniqueKeys, array $set, $fname=__METHOD__)
 Upsert row(s) into a table, in the provided order, while updating conflicting rows. More...
 
 wasConnectionLoss ()
 Determines if the last query error was due to a dropped connection. More...
 
 wasDeadlock ()
 Determines if the last failure was due to a deadlock. More...
 
 wasErrorReissuable ()
 Determines if the last query error was due to something outside of the query itself. More...
 
 wasLockTimeout ()
 Determines if the last failure was due to a lock timeout. More...
 
 wasReadOnlyError ()
 Determines if the last failure was due to the database being read-only. More...
 
 writesOrCallbacksPending ()
 Whether there is a transaction open with either possible write queries or unresolved pre-commit/commit/resolution callbacks pending. More...
 
 writesPending ()
 
- Public Member Functions inherited from Wikimedia\Rdbms\Platform\ISQLPlatform
 addIdentifierQuotes ( $s)
 Escape a SQL identifier (e.g. More...
 
 anyChar ()
 Returns a token for buildLike() that denotes a '_' to be used in a LIKE query. More...
 
 anyString ()
 Returns a token for buildLike() that denotes a '' to be used in a LIKE query. More...
 
 bitAnd ( $fieldLeft, $fieldRight)
 
 bitNot ( $field)
 
 bitOr ( $fieldLeft, $fieldRight)
 
 buildConcat ( $stringList)
 Build a concatenation list to feed into a SQL query. More...
 
 buildGreatest ( $fields, $values)
 Build a GREATEST function statement comparing columns/values. More...
 
 buildIntegerCast ( $field)
 
 buildLeast ( $fields, $values)
 Build a LEAST function statement comparing columns/values. More...
 
 buildLike ( $param,... $params)
 LIKE statement wrapper. More...
 
 buildStringCast ( $field)
 
 buildSubString ( $input, $startPosition, $length=null)
 Build a SUBSTRING function. More...
 
 conditional ( $cond, $caseTrueExpression, $caseFalseExpression)
 Returns an SQL expression for a simple conditional. More...
 
 decodeExpiry ( $expiry, $format=TS_MW)
 Decode an expiry time into a DBMS independent format. More...
 
 encodeExpiry ( $expiry)
 Encode an expiry time into the DBMS dependent format. More...
 
 factorConds ( $condsArray)
 Given an array of condition arrays representing an OR list of AND lists, for example: More...
 
 getInfinity ()
 Find out when 'infinity' is. More...
 
 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. More...
 
 limitResult ( $sql, $limit, $offset=false)
 Construct a LIMIT query with optional offset. More...
 
 makeList (array $a, $mode=self::LIST_COMMA)
 Makes an encoded list of strings from an array. More...
 
 makeWhereFrom2d ( $data, $baseKey, $subKey)
 Build a partial where clause from a 2-d array such as used for LinkBatch. More...
 
 strreplace ( $orig, $old, $new)
 Returns a SQL expression for simple string replacement (e.g. More...
 
 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. More...
 
 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. More...
 
 unionQueries ( $sqls, $all)
 Construct a UNION query. More...
 
 unionSupportsOrderAndLimit ()
 Determine if the RDBMS supports ORDER BY and LIMIT for separate subqueries within UNION. More...
 
- Public Member Functions inherited from Wikimedia\Rdbms\Database\DbQuoter
 addQuotes ( $s)
 Escape and quote a raw value string for use in a SQL query. More...
 

Additional Inherited Members

- Public Attributes inherited from Wikimedia\Rdbms\IDatabase
const LOCK_TIMESTAMP = 1
 Flag to return the lock acquisition timestamp (null if not acquired) More...
 
const QUERY_PSEUDO_PERMANENT = 2
 Track a TEMPORARY table CREATE as if it was for a permanent table (for testing) More...
 

Detailed Description

Advanced database interface for IDatabase handles that include maintenance methods.

This is useful for type-hints used by installer, upgrader, and background scripts that will make use of lower-level and longer-running queries, including schema changes.

Since
1.28

Definition at line 38 of file IMaintainableDatabase.php.

Member Function Documentation

◆ deadlockLoop()

Wikimedia\Rdbms\IMaintainableDatabase::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.

Parameters
mixed...$args
Returns
mixed
Exceptions
DBUnexpectedError
Exception

Implemented in Wikimedia\Rdbms\DBConnRef, Wikimedia\Rdbms\DatabaseSqlite, and Wikimedia\Rdbms\Database.

◆ dropTable()

Wikimedia\Rdbms\IMaintainableDatabase::dropTable (   $table,
  $fname = __METHOD__ 
)

Delete a table.

Parameters
string$table
string$fname
Returns
bool Whether the table already existed
Exceptions
DBErrorIf an error occurs

Implemented in Wikimedia\Rdbms\DBConnRef, Wikimedia\Rdbms\DatabaseSqlite, and Wikimedia\Rdbms\Database.

◆ duplicateTableStructure()

Wikimedia\Rdbms\IMaintainableDatabase::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).

Parameters
string$oldNameName of table whose structure should be copied
string$newNameName of table to be created
bool$temporaryWhether the new table should be temporary
string$fnameCalling function name
Returns
bool True if operation was successful
Exceptions
RuntimeException

Implemented in Wikimedia\Rdbms\DBConnRef, Wikimedia\Rdbms\DatabaseSqlite, Wikimedia\Rdbms\DatabasePostgres, Wikimedia\Rdbms\DatabaseMysqlBase, and Wikimedia\Rdbms\Database.

◆ fieldInfo()

Wikimedia\Rdbms\IMaintainableDatabase::fieldInfo (   $table,
  $field 
)

Get information about a field Returns false if the field doesn't exist.

Parameters
string$tableTable name
string$fieldField name
Returns
false|Field

Implemented in Wikimedia\Rdbms\DBConnRef, Wikimedia\Rdbms\DatabaseSqlite, Wikimedia\Rdbms\DatabasePostgres, and Wikimedia\Rdbms\DatabaseMysqlBase.

◆ indexUnique()

Wikimedia\Rdbms\IMaintainableDatabase::indexUnique (   $table,
  $index,
  $fname = __METHOD__ 
)

Determines if a given index is unique.

Parameters
string$table
string$index
string$fnameCalling function name
Returns
bool

Implemented in Wikimedia\Rdbms\DBConnRef, Wikimedia\Rdbms\DatabaseSqlite, Wikimedia\Rdbms\DatabasePostgres, and Wikimedia\Rdbms\Database.

◆ listTables()

Wikimedia\Rdbms\IMaintainableDatabase::listTables (   $prefix = null,
  $fname = __METHOD__ 
)

List all tables on the database.

Parameters
string | null$prefixOnly show tables with this prefix, e.g. mw_
string$fnameCalling function name
Exceptions
DBError
Returns
array

Implemented in Wikimedia\Rdbms\DBConnRef, Wikimedia\Rdbms\DatabaseSqlite, Wikimedia\Rdbms\DatabaseMysqlBase, Wikimedia\Rdbms\Database, and Wikimedia\Rdbms\DatabasePostgres.

◆ listViews()

Wikimedia\Rdbms\IMaintainableDatabase::listViews (   $prefix = null,
  $fname = __METHOD__ 
)

Lists all the VIEWs in the database.

Parameters
string | null$prefixOnly show VIEWs with this prefix, eg. unit_test_
string$fnameName of calling function
Exceptions
RuntimeException
Returns
array

Implemented in Wikimedia\Rdbms\DBConnRef, Wikimedia\Rdbms\DatabaseMysqlBase, and Wikimedia\Rdbms\Database.

◆ sourceFile()

Wikimedia\Rdbms\IMaintainableDatabase::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).

Parameters
string$filenameFile name to open
callable | null$lineCallbackOptional function called before reading each line
callable | null$resultCallbackOptional function called for each MySQL result
bool | string$fnameCalling function name or false if name should be generated dynamically using $filename
callable | null$inputCallbackOptional function called for each complete line sent
Returns
bool|string
Exceptions
Exception

Implemented in Wikimedia\Rdbms\DBConnRef, and Wikimedia\Rdbms\Database.

◆ sourceStream()

Wikimedia\Rdbms\IMaintainableDatabase::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).

Parameters
resource$fpFile handle
callable | null$lineCallbackOptional function called before reading each query
callable | null$resultCallbackOptional function called for each MySQL result
string$fnameCalling function name
callable | null$inputCallbackOptional function called for each complete query sent
Returns
bool|string

Implemented in Wikimedia\Rdbms\DBConnRef, and Wikimedia\Rdbms\Database.

◆ streamStatementEnd()

Wikimedia\Rdbms\IMaintainableDatabase::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

Implemented in Wikimedia\Rdbms\DBConnRef, Wikimedia\Rdbms\DatabasePostgres, Wikimedia\Rdbms\DatabaseMysqlBase, and Wikimedia\Rdbms\Database.

◆ tableName()

Wikimedia\Rdbms\IMaintainableDatabase::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.

Note
This function does not sanitize user input. It is not safe to use this function to escape user input.
Parameters
string$nameDatabase table name
string$formatOne 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
Returns
string Full database name

Implemented in Wikimedia\Rdbms\DBConnRef, Wikimedia\Rdbms\DatabaseSqlite, and Wikimedia\Rdbms\Database.

Referenced by SqlBagOStuff\initSqliteDatabase().

◆ tableNames()

Wikimedia\Rdbms\IMaintainableDatabase::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";

Parameters
string...$tables
Returns
array

Implemented in Wikimedia\Rdbms\DBConnRef, and Wikimedia\Rdbms\Database.

◆ tableNamesN()

Wikimedia\Rdbms\IMaintainableDatabase::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";

Parameters
string...$tables
Returns
array

Implemented in Wikimedia\Rdbms\DBConnRef, and Wikimedia\Rdbms\Database.

◆ textFieldSize()

Wikimedia\Rdbms\IMaintainableDatabase::textFieldSize (   $table,
  $field 
)

Returns the size of a text field, or -1 for "unlimited".

Parameters
string$table
string$field
Returns
int

Implemented in Wikimedia\Rdbms\DBConnRef, Wikimedia\Rdbms\DatabaseSqlite, Wikimedia\Rdbms\DatabasePostgres, and Wikimedia\Rdbms\Database.

◆ truncate()

Wikimedia\Rdbms\IMaintainableDatabase::truncate (   $tables,
  $fname = __METHOD__ 
)

Delete all data in a table(s) and reset any sequences owned by that table(s)

Parameters
string | string[]$tables
string$fname
Exceptions
DBErrorIf an error occurs
Since
1.35

Implemented in Wikimedia\Rdbms\DBConnRef, and Wikimedia\Rdbms\Database.


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