Manual:Database.php

From mediawiki.org
This page is a translated version of the page Manual:Database.php and the translation is 54% complete.

説明

Database.php contains the Database class (formerly DatabaseBase) that serves as a base for all database classes (MySQL, PostgreSQL, etc).

関数

These are invoked using the database abstraction layer accessed via wfGetDB(), e.g. $dbw->affectedRows().

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

名前 説明
affectedRows () 前回の書き込みクエリの影響を受けたレコードの件数を取得します。
dataSeek ($res, $row) 結果オブジェクト内のカーソルの位置を変更します。
fetchObject ($res) 指定した結果オブジェクトから次のレコードを、オブジェクト形式で取得します。
fetchRow ($res) 指定した結果オブジェクトから次のレコードを、連想配列形式で取得します。
fieldInfo ($table, $field) フィールドが存在しない場合は false を返します。
fieldName ($res, $n) 結果オブジェクト内のフィールド名を取得します。
getServerInfo () A string describing the current software version, and possibly other details in a user-friendly way.
getServerVersion () A string describing the current software version, like from mysql_get_server_info().
getSoftwareLink () Returns a wikitext link to the DB's website, e.g., return "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 () 前回のエラー番号を取得します。
lastError () 前回のエラーの説明を取得します。
numFields ($res) 結果オブジェクト内のフィールド数を取得します。
numRows ($res) 結果オブジェクト内のレコード数を取得します。
open ($server, $user, $password, $dbName) データベースへの接続を開きます。
strencode ($s) Wrapper for addslashes().
tableExists ($table) Returns false if the $table doesn't exist.

タイムスタンプ関数

名前 説明
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.


関連項目