Movatterモバイル変換


[0]ホーム

URL:


Jump to content
MediaWiki
Search

Manual:Database.php

From mediawiki.org
Translate this page
Languages:
MediaWiki file: Database.php
Location:includes/libs/rdbms/database/
Source code:master1.44.01.43.31.39.13
Classes:Wikimedia\Rdbms\Database

Description

[edit]

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

Generally this class is not invoked directly by developers, but instead through thedatabase abstraction layer.

Implements

[edit]

Functions

[edit]

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

NameDescription
affectedRows ()Get the number of rows affected by the last write query.
dataSeek ($res, $row)Change the position of the cursor in a result object.
fieldInfo ($table, $field)Returnsfalse if the field doesn't exist.
fieldName ($res, $n)Get a field name in a result object.
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 frommysql_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 ()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 foraddslashes().
tableExists ($table)Returnsfalse if the$table doesn't exist.
fieldExists( ... )

indexExists( ... )

Other boolean methods for running checks.

Methods for building SQL queries

newSelectQueryBuilder()Get a new instance ofSelectQueryBuilder bound to the present connection. Overridden byDBConnRef.
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( ... )

selectRowCount( ... )

lockForUpdate( ... )Locks rows returned by SELECT query


Timestamp functions

[edit]
timestamp ( $ts = 0 )Convert a timestamp in one of the formats accepted bywfTimestamp() to the format used for inserting into timestamp fields in this DBMS. The result is unquoted, and needs to be passed throughaddQuotes() before it can be included in raw SQL.
timestampOrNull ( $ts = null )Convert a timestamp in one of the formats accepted bywfTimestamp() 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 throughaddQuotes() before it can be included in raw SQL.

Extended by

[edit]

See also

[edit]
Engines
Current
Former
Technical documentation
Configuration
Development
Core tables
Current
Former
Retrieved from "https://www.mediawiki.org/w/index.php?title=Manual:Database.php&oldid=6582097"
Category:

[8]ページ先頭

©2009-2025 Movatter.jp