Manual:Database.php
Appearance
Outdated translations are marked like this.
Arquivo MediaWiki: Database.php | |
---|---|
Local: | includes/libs/rdbms/database/ |
Código fonte: | master • 1.42.4 • 1.41.5 • 1.39.11 |
Classes: | Wikimedia\Rdbms\Database |
Descrição
O arquivo Database.php contém a classe DatabaseBase
que serve de base para todas as classes de banco de dados (MySQL, PostgreSQL, etc). Ele também contém a interface DatabaseType
, que tem um certo número de funções convenientes.
Estas funções são invocadas usando a camada de abstração de banco de dados acessada via $2, p.ex. $3.
Implements
Funções
The following table lists only a selection of the implemented functions:
Name | Description |
---|---|
affectedRows ()
|
Obtém o número de linhas afetadas pela última consulta digitada. |
dataSeek ($res, $row)
|
Altera a posição do cursor em um objeto de resultado. |
fieldInfo ($table, $field)
|
Retorna false se o campo não existe. |
fieldName ($res, $n)
|
Obtém um nome de campo em um objeto de resultado. |
getServerInfo ()
|
Uma string que descreve a versão atual do software e, possivelmente, outros detalhes de uma forma amigável. |
getServerVersion ()
|
Uma string que descreve a versão atual do software, como a partir da função mysql_get_server_info(). |
getSoftwareLink ()
|
Retorna um link de wikitexto para o site do banco de dados, por exemplo, retorna "[$mysql MySQL]"; Should at least contain plain text, if for some reason your database has no website. |
getType ()
|
Get the type of the DBMS, as it appears in $wgDBtype .
|
indexInfo ($table, $index, $fname=__METHOD__)
|
Get information about an index into an object. |
insertId ()
|
Get the inserted value of an auto-increment row. |
lastErrno ()
|
Get the last error number. |
lastError ()
|
Get a description of the last error. |
numFields ($res)
|
Get the number of fields in a result object. |
open ($server, $user, $password, $dbName)
|
Open a connection to the database. |
strencode ($s)
|
Wrapper for addslashes() .
|
tableExists ($table)
|
Returns false if the $table doesn't exist.
|
fieldExists( ... )
|
Other boolean methods for running checks. |
Methods for building SQL queries | |
newSelectQueryBuilder()
|
Get a new instance of SelectQueryBuilder bound to the present connection. Overridden by DBConnRef . |
select( $table, $vars, $conds = '', $fname = __METHOD__, $options = [], $join_conds = [] )
|
Prepare a SELECT statement. |
selectField( $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = [] )
|
|
selectFieldValues( $table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = [] )
|
|
selectRow( $options = [], $join_conds = [] $table, $vars, $conds, $fname = __METHOD__, )
|
|
estimateRowCount( ... )
|
|
lockForUpdate( ... )
|
Locks rows returned by SELECT query
|
Funções de data e hora | |
timestamp ( $ts = 0 )
|
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting into timestamp fields in this DBMS. The result is unquoted, and needs to be passed through addQuotes() before it can be included in raw SQL.
|
timestampOrNull ( $ts = null )
|
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting into timestamp fields in this DBMS. If NULL is input, it is passed through, allowing NULL values to be inserted into timestamp fields. The result is unquoted, and needs to be passed through addQuotes() before it can be included in raw SQL.
|
Extended by
- For MySQL:
- DatabaseMySQL (MW 1.41+) - merger of DatabaseMysqlBase and DatabaseMysqli
- DatabaseMysqlBase (MW 1.39-1.40)
- DatabaseMysqli (MW 1.39-1.40)
- DatabaseSqlite
- DatabasePostgres