MediaWiki
REL1_22
|
Public Member Functions | |
addIdentifierQuotes ($s) | |
Quotes an identifier using `backticks` or "double quotes" depending on the database type. | |
addQuotes ($s) | |
Adds quotes and backslashes. | |
affectedRows () | |
Get the number of rows affected by the last write query. | |
buildConcat ($stringList) | |
Build a concatenation list to feed into a SQL query. | |
cascadingDeletes () | |
Returns true if this database supports (and uses) cascading deletes. | |
cleanupTriggers () | |
Returns true if this database supports (and uses) triggers (e.g. | |
currentSequenceValue ($seqName) | |
Return the current value of a sequence. | |
dataSeek ($res, $row) | |
Change the position of the cursor in a result object. | |
decodeBlob ($b) | |
Some DBMSs return a special placeholder object representing blob fields in result objects. | |
encodeBlob ($b) | |
Some DBMSs have a special format for inserting into blob fields, they don't allow simple quoted strings to be inserted. | |
estimateRowCount ($table, $vars= '*', $conds= '', $fname=__METHOD__, $options=array()) | |
Estimate rows in dataset Returns estimated count, based on SHOWPLAN_ALL output This is not necessarily an accurate estimate, so use sparingly Returns -1 if count cannot be found Takes same arguments as Database::select() | |
fetchObject ($res) | |
Fetch the next row from the given result object, in object form. | |
fetchRow ($res) | |
Fetch the next row from the given result object, in associative array form. | |
fieldExists ($table, $field, $fname=__METHOD__) | |
Query whether a given column exists in the mediawiki schema. | |
fieldInfo ($table, $field) | |
mysql_fetch_field() wrapper Returns false if the field doesn't exist | |
fieldName ($res, $n) | |
Get a field name in a result object. | |
freeResult ($res) | |
Free a result object returned by query() or select(). | |
functionalIndexes () | |
Returns true if this database can use functional indexes. | |
getErrors () | |
getInfinity () | |
Since MSSQL doesn't recognize the infinity keyword, set date manually. | |
getSearchEngine () | |
Get search engine class. | |
getServerVersion () | |
getSoftwareLink () | |
getType () | |
Get the type of the DBMS, as it appears in $wgDBtype. | |
implicitGroupby () | |
Returns true if this database does an implicit sort when doing GROUP BY. | |
implicitOrderby () | |
Returns true if this database does an implicit order by when the column has an index For example: SELECT page_title FROM page LIMIT 1. | |
indexInfo ($table, $index, $fname=__METHOD__) | |
Returns information about an index If errors are explicitly ignored, returns NULL on failure. | |
initial_setup ($dbName, $newUser, $loginPassword) | |
Initial setup. | |
insert ($table, $arrToInsert, $fname=__METHOD__, $options=array()) | |
INSERT wrapper, inserts an array into a table. | |
insertId () | |
This must be called after nextSequenceVal. | |
insertSelect ($destTable, $srcTable, $varMap, $conds, $fname=__METHOD__, $insertOptions=array(), $selectOptions=array()) | |
INSERT SELECT wrapper $varMap must be an associative array of the form array( 'dest1' => 'source1', ...) Source items may be literals rather than field names, but strings should be quoted with Database::addQuotes() $conds may be "*" to copy the whole table srcTable may be an array of tables. | |
isQuotedIdentifier ($name) | |
Returns if the given identifier looks quoted or not according to the database convention for quoting identifiers . | |
lastErrno () | |
Get the last error number. | |
lastError () | |
Get a description of the last error. | |
limitResult ($sql, $limit, $offset=false) | |
Construct a LIMIT query with optional offset This is used for query pages $sql string SQL query we will append the limit too $limit integer the SQL limit $offset integer the SQL offset (default false) | |
LimitToTopN ($sql) | |
makeSelectOptions ($options) | |
nextSequenceValue ($seqName) | |
Return the next in a sequence, save the value for retrieval via insertId() | |
numFields ($res) | |
Get the number of fields in a result object. | |
numRows ($res) | |
Get the number of rows in a result object. | |
open ($server, $user, $password, $dbName) | |
Usually aborts on failure. | |
realTimestamps () | |
Returns true if this database uses timestamps rather than integers. | |
select ($table, $vars, $conds= '', $fname=__METHOD__, $options=array(), $join_conds=array()) | |
SELECT wrapper. | |
selectDB ($db) | |
Change the current database. | |
selectSQLText ($table, $vars, $conds= '', $fname=__METHOD__, $options=array(), $join_conds=array()) | |
SELECT wrapper. | |
strencode ($s) | |
Wrapper for addslashes() | |
strictIPs () | |
Returns true if this database is strict about what can be put into an IP field. | |
tableExists ($table, $fname=__METHOD__, $schema=false) | |
tableNamesWithUseIndexOrJOIN ($tables, $use_index=array(), $join_conds=array()) | |
textFieldSize ($table, $field) | |
Returns the size of a text field, or -1 for "unlimited". | |
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. | |
unionSupportsOrderAndLimit () | |
Returns true if current database backend supports ORDER BY or LIMIT for separate subqueries within the UNION construct. | |
Public Attributes | |
$mAffectedRows = null | |
$mInsertId = null | |
$mLastResult = null | |
$mPort | |
Protected Member Functions | |
closeConnection () | |
Closes a database connection, if it is open Returns success, true if already closed. | |
doBegin ($fname=__METHOD__) | |
Begin a transaction, committing any previously open transaction. | |
doCommit ($fname=__METHOD__) | |
End a transaction. | |
doQuery ($sql) | |
The DBMS-dependent part of query() | |
doRollback ($fname=__METHOD__) | |
Rollback a transaction. | |
Private Member Functions | |
escapeIdentifier ($identifier) | |
Escapes a identifier for use inm SQL. |
Definition at line 30 of file DatabaseMssql.php.
Quotes an identifier using `backticks` or "double quotes" depending on the database type.
MySQL uses `backticks` while basically everything else uses double quotes. Since MySQL is the odd one out here the double quotes are our generic and we implement backticks in DatabaseMysql.
$s | string |
Reimplemented from DatabaseBase.
Definition at line 887 of file DatabaseMssql.php.
References $s.
DatabaseMssql::addQuotes | ( | $ | s | ) |
Adds quotes and backslashes.
$s | string |
Reimplemented from DatabaseBase.
Definition at line 879 of file DatabaseMssql.php.
References $s.
Referenced by initial_setup(), and insert().
Get the number of rows affected by the last write query.
Implements DatabaseType.
Definition at line 283 of file DatabaseMssql.php.
DatabaseMssql::buildConcat | ( | $ | stringList | ) |
Build a concatenation list to feed into a SQL query.
array | $stringList | list of raw SQL expressions; caller is responsible for any quoting |
Reimplemented from DatabaseBase.
Definition at line 938 of file DatabaseMssql.php.
Returns true if this database supports (and uses) cascading deletes.
Reimplemented from DatabaseBase.
Definition at line 37 of file DatabaseMssql.php.
Returns true if this database supports (and uses) triggers (e.g.
on the page table)
Reimplemented from DatabaseBase.
Definition at line 41 of file DatabaseMssql.php.
DatabaseMssql::closeConnection | ( | ) | [protected] |
Closes a database connection, if it is open Returns success, true if already closed.
Reimplemented from DatabaseBase.
Definition at line 140 of file DatabaseMssql.php.
DatabaseMssql::currentSequenceValue | ( | $ | seqName | ) |
Return the current value of a sequence.
Assumes it has ben nextval'ed in this session.
Definition at line 577 of file DatabaseMssql.php.
References $ret, and nextSequenceValue().
DatabaseMssql::dataSeek | ( | $ | res, |
$ | row | ||
) |
Change the position of the cursor in a result object.
$res | Mixed: A SQL result |
$row | Mixed: Either MySQL row or ResultWrapper |
Implements DatabaseType.
Definition at line 259 of file DatabaseMssql.php.
References $res.
DatabaseMssql::decodeBlob | ( | $ | b | ) |
Some DBMSs return a special placeholder object representing blob fields in result objects.
Pass the object through this function to return the original string.
$b | string |
Reimplemented from DatabaseBase.
Definition at line 832 of file DatabaseMssql.php.
DatabaseMssql::doBegin | ( | $ | fname = __METHOD__ | ) | [protected] |
Begin a transaction, committing any previously open transaction.
Reimplemented from DatabaseBase.
Definition at line 724 of file DatabaseMssql.php.
DatabaseMssql::doCommit | ( | $ | fname = __METHOD__ | ) | [protected] |
End a transaction.
Reimplemented from DatabaseBase.
Definition at line 732 of file DatabaseMssql.php.
DatabaseMssql::doQuery | ( | $ | sql | ) | [protected] |
The DBMS-dependent part of query()
$sql | String: SQL query. |
Reimplemented from DatabaseBase.
Definition at line 144 of file DatabaseMssql.php.
References $error, $matches, $res, as, LimitToTopN(), and wfDebug().
Referenced by initial_setup(), and insert().
DatabaseMssql::doRollback | ( | $ | fname = __METHOD__ | ) | [protected] |
Rollback a transaction.
No-op on non-transactional databases.
Reimplemented from DatabaseBase.
Definition at line 741 of file DatabaseMssql.php.
DatabaseMssql::encodeBlob | ( | $ | b | ) |
Some DBMSs have a special format for inserting into blob fields, they don't allow simple quoted strings to be inserted.
To insert into such a field, pass the data through this function before passing it to DatabaseBase::insert().
$b | string |
Reimplemented from DatabaseBase.
Definition at line 827 of file DatabaseMssql.php.
DatabaseMssql::escapeIdentifier | ( | $ | identifier | ) | [private] |
Escapes a identifier for use inm SQL.
Throws an exception if it is invalid. Reference: http://msdn.microsoft.com/en-us/library/aa224033%28v=SQL.80%29.aspx
$identifier |
MWException |
Definition at line 754 of file DatabaseMssql.php.
Referenced by initial_setup().
DatabaseMssql::estimateRowCount | ( | $ | table, |
$ | vars = '*' , |
||
$ | conds = '' , |
||
$ | fname = __METHOD__ , |
||
$ | options = array() |
||
) |
Estimate rows in dataset Returns estimated count, based on SHOWPLAN_ALL output This is not necessarily an accurate estimate, so use sparingly Returns -1 if count cannot be found Takes same arguments as Database::select()
Reimplemented from DatabaseBase.
Definition at line 340 of file DatabaseMssql.php.
References $fname, $options, $res, $vars, fetchRow(), and select().
DatabaseMssql::fetchObject | ( | $ | res | ) |
Fetch the next row from the given result object, in object form.
Fields can be retrieved with $row->fieldname, with fields acting like member variables. If no more rows are available, false is returned.
$res | ResultWrapper|object as returned from DatabaseBase::query(), etc. |
DBUnexpectedError | Thrown if the database returns an error |
Implements DatabaseType.
Definition at line 199 of file DatabaseMssql.php.
References $res.
DatabaseMssql::fetchRow | ( | $ | res | ) |
Fetch the next row from the given result object, in associative array form.
Fields are retrieved with $row['fieldname']. If no more rows are available, false is returned.
$res | ResultWrapper result object as returned from DatabaseBase::query(), etc. |
DBUnexpectedError | Thrown if the database returns an error |
Implements DatabaseType.
Definition at line 222 of file DatabaseMssql.php.
References $res.
Referenced by estimateRowCount(), fieldInfo(), and textFieldSize().
DatabaseMssql::fieldExists | ( | $ | table, |
$ | field, | ||
$ | fname = __METHOD__ |
||
) |
Query whether a given column exists in the mediawiki schema.
Reimplemented from DatabaseBase.
Definition at line 691 of file DatabaseMssql.php.
References $res, getErrors(), print, and DatabaseBase\tableName().
DatabaseMssql::fieldInfo | ( | $ | table, |
$ | field | ||
) |
mysql_fetch_field() wrapper Returns false if the field doesn't exist
string | $table | table name |
string | $field | field name |
Implements DatabaseType.
Definition at line 706 of file DatabaseMssql.php.
References $res, fetchRow(), getErrors(), print, and DatabaseBase\tableName().
DatabaseMssql::fieldName | ( | $ | res, |
$ | n | ||
) |
Get a field name in a result object.
$res | Mixed: A SQL result |
$n | Integer |
Implements DatabaseType.
Definition at line 244 of file DatabaseMssql.php.
DatabaseMssql::freeResult | ( | $ | res | ) |
Free a result object returned by query() or select().
It's usually not necessary to call this, just use unset() or let the variable holding the result object go out of scope.
$res | Mixed: A SQL result |
Reimplemented from DatabaseBase.
Definition at line 192 of file DatabaseMssql.php.
References $res.
Returns true if this database can use functional indexes.
Reimplemented from DatabaseBase.
Definition at line 61 of file DatabaseMssql.php.
Definition at line 207 of file DatabaseMssql.php.
References as.
Referenced by fieldExists(), fieldInfo(), insert(), insertSelect(), lastError(), and tableExists().
Since MSSQL doesn't recognize the infinity keyword, set date manually.
Reimplemented from DatabaseBase.
Definition at line 951 of file DatabaseMssql.php.
Get search engine class.
All subclasses of this need to implement this if they wish to use searching.
Reimplemented from DatabaseBase.
Definition at line 942 of file DatabaseMssql.php.
Implements DatabaseType.
Definition at line 664 of file DatabaseMssql.php.
Implements DatabaseType.
Definition at line 657 of file DatabaseMssql.php.
Get the type of the DBMS, as it appears in $wgDBtype.
Implements DatabaseType.
Definition at line 934 of file DatabaseMssql.php.
Returns true if this database does an implicit sort when doing GROUP BY.
Reimplemented from DatabaseBase.
Definition at line 53 of file DatabaseMssql.php.
Returns true if this database does an implicit order by when the column has an index For example: SELECT page_title FROM page LIMIT 1.
Reimplemented from DatabaseBase.
Definition at line 57 of file DatabaseMssql.php.
DatabaseMssql::indexInfo | ( | $ | table, |
$ | index, | ||
$ | fname = __METHOD__ |
||
) |
Returns information about an index If errors are explicitly ignored, returns NULL on failure.
Implements DatabaseType.
Definition at line 359 of file DatabaseMssql.php.
References $fname, $res, $result, array(), as, empty, and DatabaseBase\query().
DatabaseMssql::initial_setup | ( | $ | dbName, |
$ | newUser, | ||
$ | loginPassword | ||
) |
Initial setup.
Precondition: This object is connected as the superuser. Creates the database, schema, user and login.
Definition at line 773 of file DatabaseMssql.php.
References addQuotes(), doQuery(), and escapeIdentifier().
DatabaseMssql::insert | ( | $ | table, |
$ | arrToInsert, | ||
$ | fname = __METHOD__ , |
||
$ | options = array() |
||
) |
INSERT wrapper, inserts an array into a table.
$arrToInsert may be a single associative array, or an array of these with numeric keys, for multi-row insert.
Usually aborts on failure If errors are explicitly ignored, returns success
string | $table | |
array | $arrToInsert | |
string | $fname | |
array | $options |
DBQueryError |
Reimplemented from DatabaseBase.
Definition at line 404 of file DatabaseMssql.php.
References $fname, $keys, $options, $res, $ret, $value, addQuotes(), array(), as, doQuery(), getErrors(), lastErrno(), and DatabaseBase\tableName().
This must be called after nextSequenceVal.
Implements DatabaseType.
Definition at line 255 of file DatabaseMssql.php.
DatabaseMssql::insertSelect | ( | $ | destTable, |
$ | srcTable, | ||
$ | varMap, | ||
$ | conds, | ||
$ | fname = __METHOD__ , |
||
$ | insertOptions = array() , |
||
$ | selectOptions = array() |
||
) |
INSERT SELECT wrapper $varMap must be an associative array of the form array( 'dest1' => 'source1', ...) Source items may be literals rather than field names, but strings should be quoted with Database::addQuotes() $conds may be "*" to copy the whole table srcTable may be an array of tables.
string | $destTable | |
array | string | $srcTable | |
array | $varMap | |
array | $conds | |
string | $fname | |
array | $insertOptions | |
array | $selectOptions |
DBQueryError |
Reimplemented from DatabaseBase.
Definition at line 542 of file DatabaseMssql.php.
References $fname, $ret, getErrors(), and lastErrno().
DatabaseMssql::isQuotedIdentifier | ( | $ | name | ) |
Returns if the given identifier looks quoted or not according to the database convention for quoting identifiers .
$name | string |
Reimplemented from DatabaseBase.
Definition at line 892 of file DatabaseMssql.php.
References $name.
Get the last error number.
Implements DatabaseType.
Definition at line 274 of file DatabaseMssql.php.
Referenced by insert(), and insertSelect().
Get a description of the last error.
Implements DatabaseType.
Definition at line 266 of file DatabaseMssql.php.
References getErrors().
Referenced by open().
DatabaseMssql::limitResult | ( | $ | sql, |
$ | limit, | ||
$ | offset = false |
||
) |
Construct a LIMIT query with optional offset This is used for query pages $sql string SQL query we will append the limit too $limit integer the SQL limit $offset integer the SQL offset (default false)
Reimplemented from DatabaseBase.
Definition at line 610 of file DatabaseMssql.php.
References $limit.
Referenced by LimitToTopN().
DatabaseMssql::LimitToTopN | ( | $ | sql | ) |
Definition at line 632 of file DatabaseMssql.php.
References $matches, and limitResult().
Referenced by doQuery().
DatabaseMssql::makeSelectOptions | ( | $ | options | ) |
array | $options | an associative array of options to be turned into an SQL query, valid keys are listed in the function. |
Reimplemented from DatabaseBase.
Definition at line 907 of file DatabaseMssql.php.
References $key, $options, array(), as, DatabaseBase\makeGroupByWithHaving(), and DatabaseBase\makeOrderBy().
DatabaseMssql::nextSequenceValue | ( | $ | seqName | ) |
Return the next in a sequence, save the value for retrieval via insertId()
Reimplemented from DatabaseBase.
Definition at line 560 of file DatabaseMssql.php.
References $ret, and tableExists().
Referenced by currentSequenceValue().
DatabaseMssql::numFields | ( | $ | res | ) |
Get the number of fields in a result object.
$res | Mixed: A SQL result |
Implements DatabaseType.
Definition at line 237 of file DatabaseMssql.php.
References $res.
DatabaseMssql::numRows | ( | $ | res | ) |
Get the number of rows in a result object.
$res | Mixed: A SQL result |
Implements DatabaseType.
Definition at line 230 of file DatabaseMssql.php.
References $res.
DatabaseMssql::open | ( | $ | server, |
$ | user, | ||
$ | password, | ||
$ | dbName | ||
) |
Usually aborts on failure.
string | $server | |
string | $user | |
string | $password | |
string | $dbName |
DBConnectionError |
Implements DatabaseType.
Definition at line 78 of file DatabaseMssql.php.
References $password, $user, array(), DatabaseBase\close(), e, global, is, lastError(), wfDebug(), wfRestoreWarnings(), and wfSuppressWarnings().
Returns true if this database uses timestamps rather than integers.
Reimplemented from DatabaseBase.
Definition at line 49 of file DatabaseMssql.php.
DatabaseMssql::select | ( | $ | table, |
$ | vars, | ||
$ | conds = '' , |
||
$ | fname = __METHOD__ , |
||
$ | options = array() , |
||
$ | join_conds = array() |
||
) |
SELECT wrapper.
$table | Mixed: array or string, table name(s) (prefix auto-added) | |
$vars | Mixed: array or string, field name(s) to be retrieved | |
$conds | Mixed: array or string, condition(s) for WHERE | |
$fname | String: calling function name (use __METHOD__) for logs/profiling | |
array | $options | associative array of options (e.g. array('GROUP BY' => 'page_title')), see Database::makeSelectOptions code for list of supported stuff |
$join_conds | Array: Associative array of table join conditions (optional) (e.g. array( 'page' => array('LEFT JOIN','page_latest=rev_id') ) |
Reimplemented from DatabaseBase.
Definition at line 300 of file DatabaseMssql.php.
References $fname, $options, $ret, $vars, DatabaseBase\query(), and selectSQLText().
Referenced by estimateRowCount().
DatabaseMssql::selectDB | ( | $ | db | ) |
Change the current database.
$db |
Reimplemented from DatabaseBase.
Definition at line 896 of file DatabaseMssql.php.
References DatabaseBase\query().
DatabaseMssql::selectSQLText | ( | $ | table, |
$ | vars, | ||
$ | conds = '' , |
||
$ | fname = __METHOD__ , |
||
$ | options = array() , |
||
$ | join_conds = array() |
||
) |
SELECT wrapper.
$table | Mixed: Array or string, table name(s) (prefix auto-added) | |
$vars | Mixed: Array or string, field name(s) to be retrieved | |
$conds | Mixed: Array or string, condition(s) for WHERE | |
$fname | String: Calling function name (use __METHOD__) for logs/profiling | |
array | $options | Associative array of options (e.g. array('GROUP BY' => 'page_title')), see Database::makeSelectOptions code for list of supported stuff |
$join_conds | Array: Associative array of table join conditions (optional) (e.g. array( 'page' => array('LEFT JOIN','page_latest=rev_id') ) |
Reimplemented from DatabaseBase.
Definition at line 325 of file DatabaseMssql.php.
References $fname, $options, and $vars.
Referenced by select().
DatabaseMssql::strencode | ( | $ | s | ) |
Wrapper for addslashes()
string | $s | to be slashed. |
Implements DatabaseType.
Definition at line 875 of file DatabaseMssql.php.
References $s.
Returns true if this database is strict about what can be put into an IP field.
Specifically, it uses a NULL value instead of an empty string.
Reimplemented from DatabaseBase.
Definition at line 45 of file DatabaseMssql.php.
DatabaseMssql::tableExists | ( | $ | table, |
$ | fname = __METHOD__ , |
||
$ | schema = false |
||
) |
Definition at line 673 of file DatabaseMssql.php.
References $res, getErrors(), and print.
Referenced by nextSequenceValue().
DatabaseMssql::tableNamesWithUseIndexOrJOIN | ( | $ | tables, |
$ | use_index = array() , |
||
$ | join_conds = array() |
||
) |
Reimplemented from DatabaseBase.
Definition at line 841 of file DatabaseMssql.php.
References $ret, array(), as, empty, DatabaseBase\makeList(), DatabaseBase\tableName(), and DatabaseBase\useIndexClause().
DatabaseMssql::textFieldSize | ( | $ | table, |
$ | field | ||
) |
Returns the size of a text field, or -1 for "unlimited".
$table | string |
$field | string |
Reimplemented from DatabaseBase.
Definition at line 589 of file DatabaseMssql.php.
References $res, $size, fetchRow(), DatabaseBase\query(), and DatabaseBase\tableName().
DatabaseMssql::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.
$ts | string|int |
Reimplemented from DatabaseBase.
Definition at line 650 of file DatabaseMssql.php.
References wfTimestamp().
Returns true if current database backend supports ORDER BY or LIMIT for separate subqueries within the UNION construct.
Reimplemented from DatabaseBase.
Definition at line 65 of file DatabaseMssql.php.
DatabaseMssql::$mAffectedRows = null |
Definition at line 33 of file DatabaseMssql.php.
DatabaseMssql::$mInsertId = null |
Definition at line 31 of file DatabaseMssql.php.
DatabaseMssql::$mLastResult = null |
Definition at line 32 of file DatabaseMssql.php.
DatabaseMssql::$mPort |
Definition at line 35 of file DatabaseMssql.php.