手册:Database.php

From mediawiki.org
This page is a translated version of the page Manual:Database.php and the translation is 82% complete.
Outdated translations are marked like this.

描述

Database.php包含Database类(以前称为DatabaseBase),该类用作所有数据库类(MySQL的基础, PostgreSQL等)。

使用通过$2访问的数据库抽象层调用这些,例如$3。

函数

The following table lists only a selection of the implemented functions:

名称 描述
affectedRows () 获取上一次写查询影响的行数。
dataSeek ($res, $row) 更改光标在结果对象中的位置。
fieldInfo ($table, $field) 如果该字段不存在,则返回false。
fieldName ($res, $n) 获取结果对象中的字段名称。
getServerInfo () 一个字符串描述当前软件版本,并可能以方用户友好的方式描述其他详细信息。
getServerVersion () 描述当前软件版本的字符串,例如mysql_get_server_info()中的字符串。
getSoftwareLink () 返回指向数据库网站的维基文字链接,例如,返回“MySQL”; 如果您的数据库没有网站,则至少应包含纯文本。
getType () 获取DBMS的类型,如$wgDBtype中所示。
indexInfo ($table, $index, $fname=__METHOD__) 获取有关对象索引的信息。
insertId () 获取自动增量行的插入值。
lastErrno () 获取最后的错误号。
lastError () 获取最后一个错误的描述。
numFields ($res) 获取结果对象中的字段数。
open ($server, $user, $password, $dbName) 打开与数据库的连接。
strencode ($s) 包装addslashes()
tableExists ($table) Returns false if the $table doesn't exist.

时间戳函数

名称 描述
timestamp ( $ts = 0 ) wfTimestamp() 接受的格式之一的时间戳转换为用于插入此DBMS中的timestamp字段的格式。 结果未加引号,需要先通过addQuotes()传递,然后才能将其包含在原始SQL中。
timestampOrNull ( $ts = null ) wfTimestamp() 接受的格式之一的时间戳转换为用于插入此DBMS中的timestamp字段的格式。 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.


参见