<?php
-
/**
* @defgroup Database Database
*
*/
/**
- * Basic database interface for live and lazy-loaded DB handles
+ * Basic database interface for live and lazy-loaded relation database handles
*
* @note: IDatabase and DBConnRef should be updated to reflect any changes
* @ingroup Database
/** @var string Estimate time to apply (scanning, applying) */
const ESTIMATE_DB_APPLY = 'apply';
+ /** @var int Combine list with comma delimeters */
+ const LIST_COMMA = 0;
+ /** @var int Combine list with AND clauses */
+ const LIST_AND = 1;
+ /** @var int Convert map into a SET clause */
+ const LIST_SET = 2;
+ /** @var int Treat as field name and do not apply value escaping */
+ const LIST_NAMES = 3;
+ /** @var int Combine list with OR clauses */
+ const LIST_OR = 4;
+
+ /** @var int Enable debug logging */
+ const DBO_DEBUG = 1;
+ /** @var int Disable query buffering (only one result set can be iterated at a time) */
+ const DBO_NOBUFFER = 2;
+ /** @var int Ignore query errors (internal use only!) */
+ const DBO_IGNORE = 4;
+ /** @var int Autoatically start transaction on first query (work with ILoadBalancer rounds) */
+ const DBO_TRX = 8;
+ /** @var int Use DBO_TRX in non-CLI mode */
+ const DBO_DEFAULT = 16;
+ /** @var int Use DB persistent connections if possible */
+ const DBO_PERSISTENT = 32;
+ /** @var int DBA session mode; mostly for Oracle */
+ const DBO_SYSDBA = 64;
+ /** @var int Schema file mode; mostly for Oracle */
+ const DBO_DDLMODE = 128;
+ /** @var int Enable SSL/TLS in connection protocol */
+ const DBO_SSL = 256;
+ /** @var int Enable compression in connection protocol */
+ const DBO_COMPRESS = 512;
+
/**
* A string describing the current software version, and possibly
* other details in a user-friendly way. Will be listed on Special:Version, etc.
public function getServerInfo();
/**
- * Turns buffering of SQL result sets on (true) or off (false). Default is
- * "on".
+ * Turns buffering of SQL result sets on (true) or off (false). Default is "on".
*
* Unbuffered queries are very troublesome in MySQL:
*
* - If another query is executed while the first query is being read
* out, the first query is killed. This means you can't call normal
- * MediaWiki functions while you are reading an unbuffered query result
- * from a normal wfGetDB() connection.
+ * Database functions while you are reading an unbuffered query result
+ * from a normal Database connection.
*
* - Unbuffered queries cause the MySQL server to use large amounts of
* memory and to hold broad locks which block other queries.
/**
* @return string
*/
+ public function getDomainID();
+
+ /**
+ * Alias for getDomainID()
+ *
+ * @return string
+ */
public function getWikiID();
/**
*
* - OFFSET: Skip this many rows at the start of the result set. OFFSET
* with LIMIT can theoretically be used for paging through a result set,
- * but this is discouraged in MediaWiki for performance reasons.
+ * but this is discouraged for performance reasons.
*
* - LIMIT: Integer: return at most this many rows. The rows are sorted
* and then the first rows are taken until the limit is reached. LIMIT
/**
* Makes an encoded list of strings from an array
*
+ * These can be used to make conjunctions or disjunctions on SQL condition strings
+ * derived from an array (see IDatabase::select() $conds documentation).
+ *
+ * Example usage:
+ * @code
+ * $sql = $db->makeList( [
+ * 'rev_user' => $id,
+ * $db->makeList( [ 'rev_minor' => 1, 'rev_len' < 500 ], $db::LIST_OR ] )
+ * ], $db::LIST_AND );
+ * @endcode
+ * This would set $sql to "rev_user = '$id' AND (rev_minor = '1' OR rev_len < '500')"
+ *
* @param array $a Containing the data
- * @param int $mode Constant
- * - LIST_COMMA: Comma separated, no field names
- * - LIST_AND: ANDed WHERE clause (without the WHERE). See the
- * documentation for $conds in IDatabase::select().
- * - LIST_OR: ORed WHERE clause (without the WHERE)
- * - LIST_SET: Comma separated with field names, like a SET clause
- * - LIST_NAMES: Comma separated field names
+ * @param int $mode IDatabase class constant:
+ * - IDatabase::LIST_COMMA: Comma separated, no field names
+ * - IDatabase::LIST_AND: ANDed WHERE clause (without the WHERE).
+ * - IDatabase::LIST_OR: ORed WHERE clause (without the WHERE)
+ * - IDatabase::LIST_SET: Comma separated with field names, like a SET clause
+ * - IDatabase::LIST_NAMES: Comma separated field names
* @throws DBError
* @return string
*/
- public function makeList( $a, $mode = LIST_COMMA );
+ public function makeList( $a, $mode = self::LIST_COMMA );
/**
* Build a partial where clause from a 2-d array such as used for LinkBatch.
*/
public function makeWhereFrom2d( $data, $baseKey, $subKey );
+ /**
+ * Return aggregated value alias
+ *
+ * @param array $valuedata
+ * @param string $valuename
+ *
+ * @return string
+ */
+ public function aggregateValue( $valuedata, $valuename = 'value' );
+
/**
* @param string $field
* @return string
$delim, $table, $field, $conds = '', $join_conds = []
);
+ /**
+ * @param string $field Field or column to cast
+ * @return string
+ * @since 1.28
+ */
+ public function buildStringCast( $field );
+
/**
* Change the current database
*
/**
* Adds quotes and backslashes.
*
- * @param string|Blob $s
- * @return string
+ * @param string|int|null|bool|Blob $s
+ * @return string|int
*/
public function addQuotes( $s );
*
* @return DBMasterPos|bool False if this is not a replica DB.
*/
- public function getSlavePos();
+ public function getReplicaPos();
/**
* Get the position of this master
* The goal of this function is to create an atomic section of SQL queries
* without having to start a new transaction if it already exists.
*
- * Atomic sections are more strict than transactions. With transactions,
- * attempting to begin a new transaction when one is already running results
- * in MediaWiki issuing a brief warning and doing an implicit commit. All
- * atomic levels *must* be explicitly closed using IDatabase::endAtomic(),
+ * All atomic levels *must* be explicitly closed using IDatabase::endAtomic(),
* and any database transactions cannot be began or committed until all atomic
* levels are closed. There is no such thing as implicitly opening or closing
* an atomic section.