MediaWiki REL1_28
|
Public Member Functions | |
addIdentifierQuotes ( $s) | |
addQuotes ( $s) | |
affectedRows () | |
buildConcat ( $stringList) | |
buildGroupConcatField ( $delim, $table, $field, $conds='', $join_conds=[]) | |
Build a GROUP_CONCAT or equivalent statement for a query. | |
buildLike () | |
MS SQL requires specifying the escape character used in a LIKE query or using Square brackets to surround characters that are to be escaped http://msdn.microsoft.com/en-us/library/ms179859.aspx Here we take the Specify-Escape-Character approach since it's less invasive, renders a query that is closer to other DB's and better at handling square bracket escaping. | |
dataSeek ( $res, $row) | |
delete ( $table, $conds, $fname=__METHOD__) | |
deleteJoin ( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname=__METHOD__) | |
dropTable ( $tableName, $fName=__METHOD__) | |
Delete a table. | |
estimateRowCount ( $table, $vars=' *', $conds='', $fname=__METHOD__, $options=[]) | |
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) | |
fetchRow ( $res) | |
fieldExists ( $table, $field, $fname=__METHOD__) | |
Query whether a given column exists in the mediawiki schema. | |
fieldInfo ( $table, $field) | |
fieldName ( $res, $n) | |
freeResult ( $res) | |
getServerVersion () | |
getSoftwareLink () | |
getType () | |
Get the type of the DBMS, as it appears in $wgDBtype. | |
ignoreErrors (array $value=null) | |
Called in the installer and updater. | |
implicitGroupby () | |
implicitOrderby () | |
indexInfo ( $table, $index, $fname=__METHOD__) | |
Returns information about an index If errors are explicitly ignored, returns NULL on failure. | |
insert ( $table, $arrToInsert, $fname=__METHOD__, $options=[]) | |
INSERT wrapper, inserts an array into a table. | |
insertId () | |
This must be called after nextSequenceVal. | |
isQuotedIdentifier ( $name) | |
lastErrno () | |
lastError () | |
limitResult ( $sql, $limit, $offset=false) | |
Construct a LIMIT query with optional offset This is used for query pages. | |
LimitToTopN ( $sql) | |
If there is a limit clause, parse it, strip it, and pass the remaining SQL through limitResult() with the appropriate parameters. | |
makeList ( $a, $mode=LIST_COMMA, $binaryColumns=[]) | |
Makes an encoded list of strings from an array. | |
makeSelectOptions ( $options) | |
nativeInsertSelect ( $destTable, $srcTable, $varMap, $conds, $fname=__METHOD__, $insertOptions=[], $selectOptions=[]) | |
INSERT SELECT wrapper $varMap must be an associative array of the form [ 'dest1' => 'source1', ... ] Source items may be literals rather than field names, but strings should be quoted with Database::addQuotes(). | |
numFields ( $res) | |
numRows ( $res) | |
open ( $server, $user, $password, $dbName) | |
Usually aborts on failure. | |
prepareStatements ( $value=null) | |
Called in the installer and updater. | |
realTableName ( $name, $format='quoted') | |
call this instead of tableName() in the updater when renaming tables | |
scrollableCursor ( $value=null) | |
Called in the installer and updater. | |
select ( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[]) | |
SELECT wrapper. | |
selectDB ( $db) | |
selectSQLText ( $table, $vars, $conds='', $fname=__METHOD__, $options=[], $join_conds=[]) | |
SELECT wrapper. | |
strencode ( $s) | |
tableExists ( $table, $fname=__METHOD__) | |
tableName ( $name, $format='quoted') | |
textFieldSize ( $table, $field) | |
unionSupportsOrderAndLimit () | |
update ( $table, $values, $conds, $fname=__METHOD__, $options=[]) | |
UPDATE wrapper. | |
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) | |
doRollback ( $fname=__METHOD__) | |
Rollback a transaction. | |
escapeLikeInternal ( $s) | |
MS SQL supports more pattern operators than other databases (ex: [,],^) | |
resultObject ( $result) | |
Protected Attributes | |
$mAffectedRows = null | |
$mBinaryColumnCache = null | |
$mBitColumnCache = null | |
$mIgnoreDupKeyErrors = false | |
$mIgnoreErrors = [] | |
$mInsertId = null | |
$mLastResult = null | |
$mPort | |
$mPrepareStatements = true | |
$mScrollableCursor = true | |
$mSubqueryId = 0 | |
Private Member Functions | |
escapeIdentifier ( $identifier) | |
Escapes a identifier for use inm SQL. | |
formatError ( $err) | |
getBinaryColumns ( $table) | |
Returns an associative array for fields that are of type varbinary, binary, or image $table can be either a raw table name or passed through tableName() first. | |
getBitColumns ( $table) | |
populateColumnCaches () | |
Definition at line 31 of file DatabaseMssql.php.
DatabaseMssql::addIdentifierQuotes | ( | $s | ) |
DatabaseMssql::addQuotes | ( | $s | ) |
DatabaseMssql::affectedRows | ( | ) |
DatabaseMssql::buildConcat | ( | $stringList | ) |
DatabaseMssql::buildGroupConcatField | ( | $delim, | |
$table, | |||
$field, | |||
$conds = '' , |
|||
$join_conds = [] |
|||
) |
Build a GROUP_CONCAT or equivalent statement for a query.
MS SQL doesn't have GROUP_CONCAT so we emulate it with other stuff (and boy is it nasty)
This is useful for combining a field for several rows into a single string. NULL values will not appear in the output, duplicated values will appear, and the resulting delimiter-separated values have no defined sort order. Code using the results may need to use the PHP unique() or sort() methods.
string | $delim | Glue to bind the results together |
string | array | $table | Table name |
string | $field | Field name |
string | array | $conds | Conditions |
string | array | $join_conds | Join conditions |
Definition at line 1233 of file DatabaseMssql.php.
References $mSubqueryId, and selectSQLText().
DatabaseMssql::buildLike | ( | ) |
MS SQL requires specifying the escape character used in a LIKE query or using Square brackets to surround characters that are to be escaped http://msdn.microsoft.com/en-us/library/ms179859.aspx Here we take the Specify-Escape-Character approach since it's less invasive, renders a query that is closer to other DB's and better at handling square bracket escaping.
Definition at line 1144 of file DatabaseMssql.php.
References $params.
|
protected |
Closes a database connection, if it is open Returns success, true if already closed.
Definition at line 121 of file DatabaseMssql.php.
DatabaseMssql::dataSeek | ( | $res, | |
$row | |||
) |
MssqlResultWrapper | $res | |
int | $row |
Definition at line 305 of file DatabaseMssql.php.
References $res.
DatabaseMssql::delete | ( | $table, | |
$conds, | |||
$fname = __METHOD__ |
|||
) |
Definition at line 468 of file DatabaseMssql.php.
DatabaseMssql::deleteJoin | ( | $delTable, | |
$joinTable, | |||
$delVar, | |||
$joinVar, | |||
$conds, | |||
$fname = __METHOD__ |
|||
) |
Definition at line 455 of file DatabaseMssql.php.
|
protected |
Begin a transaction, committing any previously open transaction.
string | $fname |
Definition at line 1027 of file DatabaseMssql.php.
|
protected |
|
protected |
string | $sql |
DBUnexpectedError |
Definition at line 147 of file DatabaseMssql.php.
References $matches, $mIgnoreErrors, $success, as, DBO_DEBUG, LimitToTopN(), and wfDebug().
Referenced by insert().
|
protected |
Rollback a transaction.
No-op on non-transactional databases.
string | $fname |
Definition at line 1046 of file DatabaseMssql.php.
DatabaseMssql::dropTable | ( | $tableName, | |
$fName = __METHOD__ |
|||
) |
Delete a table.
string | $tableName | |
string | $fName |
Definition at line 1344 of file DatabaseMssql.php.
References query, tableExists(), and tableName().
|
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
string | $identifier |
InvalidArgumentException |
Definition at line 1059 of file DatabaseMssql.php.
|
protected |
MS SQL supports more pattern operators than other databases (ex: [,],^)
string | $s |
Definition at line 1130 of file DatabaseMssql.php.
References $s.
DatabaseMssql::estimateRowCount | ( | $table, | |
$vars = '*' , |
|||
$conds = '' , |
|||
$fname = __METHOD__ , |
|||
$options = [] |
|||
) |
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()
string | $table | |
string | $vars | |
string | $conds | |
string | $fname | |
array | $options |
Definition at line 492 of file DatabaseMssql.php.
References $fname, $options, $res, $vars, fetchRow(), and select().
DatabaseMssql::fetchObject | ( | $res | ) |
MssqlResultWrapper | $res |
Definition at line 234 of file DatabaseMssql.php.
References $res.
DatabaseMssql::fetchRow | ( | $res | ) |
MssqlResultWrapper | $res |
Definition at line 243 of file DatabaseMssql.php.
References $res.
Referenced by estimateRowCount(), and textFieldSize().
DatabaseMssql::fieldExists | ( | $table, | |
$field, | |||
$fname = __METHOD__ |
|||
) |
Query whether a given column exists in the mediawiki schema.
string | $table | |
string | $field | |
string | $fname |
Definition at line 984 of file DatabaseMssql.php.
References $res, list, query, tableName(), and wfDebug().
DatabaseMssql::fieldInfo | ( | $table, | |
$field | |||
) |
Definition at line 1003 of file DatabaseMssql.php.
References $res, list, query, tableName(), and wfDebug().
DatabaseMssql::fieldName | ( | $res, | |
$n | |||
) |
mixed | $res | |
int | $n |
Definition at line 284 of file DatabaseMssql.php.
References $res.
|
private |
array | $err |
Definition at line 330 of file DatabaseMssql.php.
Referenced by lastError().
DatabaseMssql::freeResult | ( | $res | ) |
Definition at line 222 of file DatabaseMssql.php.
References $res.
|
private |
Returns an associative array for fields that are of type varbinary, binary, or image $table can be either a raw table name or passed through tableName() first.
string | $table |
Definition at line 1254 of file DatabaseMssql.php.
References populateColumnCaches().
|
private |
string | $table |
Definition at line 1271 of file DatabaseMssql.php.
References populateColumnCaches().
Referenced by selectSQLText().
DatabaseMssql::getServerVersion | ( | ) |
Definition at line 937 of file DatabaseMssql.php.
DatabaseMssql::getSoftwareLink | ( | ) |
Definition at line 930 of file DatabaseMssql.php.
DatabaseMssql::getType | ( | ) |
Get the type of the DBMS, as it appears in $wgDBtype.
Definition at line 1204 of file DatabaseMssql.php.
DatabaseMssql::ignoreErrors | ( | array | $value = null | ) |
Called in the installer and updater.
Probably doesn't need to be called anywhere else in the codebase.
array | null | $value |
Definition at line 1381 of file DatabaseMssql.php.
References $value, and wfSetVar().
DatabaseMssql::implicitGroupby | ( | ) |
Definition at line 45 of file DatabaseMssql.php.
DatabaseMssql::implicitOrderby | ( | ) |
Definition at line 49 of file DatabaseMssql.php.
DatabaseMssql::indexInfo | ( | $table, | |
$index, | |||
$fname = __METHOD__ |
|||
) |
Returns information about an index If errors are explicitly ignored, returns NULL on failure.
string | $table | |
string | $index | |
string | $fname |
Definition at line 520 of file DatabaseMssql.php.
DatabaseMssql::insert | ( | $table, | |
$arrToInsert, | |||
$fname = __METHOD__ , |
|||
$options = [] |
|||
) |
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 |
Exception |
Definition at line 568 of file DatabaseMssql.php.
References $e, $keys, $options, $res, $ret, $value, addQuotes(), as, doQuery(), getBinaryColumns(), query, serialize(), and tableName().
DatabaseMssql::insertId | ( | ) |
This must be called after nextSequenceVal.
Definition at line 296 of file DatabaseMssql.php.
References $mInsertId.
DatabaseMssql::isQuotedIdentifier | ( | $name | ) |
string | $name |
Definition at line 1120 of file DatabaseMssql.php.
References $name.
DatabaseMssql::lastErrno | ( | ) |
Definition at line 337 of file DatabaseMssql.php.
DatabaseMssql::lastError | ( | ) |
Definition at line 312 of file DatabaseMssql.php.
References as, and formatError().
Referenced by open().
DatabaseMssql::limitResult | ( | $sql, | |
$limit, | |||
$offset = false |
|||
) |
Construct a LIMIT query with optional offset This is used for query pages.
string | $sql | SQL query we will append the limit too |
int | $limit | The SQL limit |
bool | int | $offset | The SQL offset (default false) |
DBUnexpectedError |
Definition at line 856 of file DatabaseMssql.php.
References $last, $limit, and $mSubqueryId.
Referenced by LimitToTopN().
DatabaseMssql::LimitToTopN | ( | $sql | ) |
If there is a limit clause, parse it, strip it, and pass the remaining SQL through limitResult() with the appropriate parameters.
Not the prettiest solution, but better than building a whole new parser. This exists becase there are still too many extensions that don't use dynamic sql generation.
string | $sql |
Definition at line 911 of file DatabaseMssql.php.
References $matches, and limitResult().
Referenced by doQuery().
DatabaseMssql::makeList | ( | $a, | |
$mode = LIST_COMMA , |
|||
$binaryColumns = [] |
|||
) |
Makes an encoded list of strings from an array.
array | $a | Containing the data |
int | $mode | Constant
|
array | $binaryColumns | Contains a list of column names that are binary types This is a custom parameter only present for MS SQL. |
DBUnexpectedError |
Definition at line 799 of file DatabaseMssql.php.
References as, and LIST_NAMES.
Referenced by update().
DatabaseMssql::makeSelectOptions | ( | $options | ) |
array | $options | An associative array of options to be turned into an SQL query, valid keys are listed in the function. |
Definition at line 1172 of file DatabaseMssql.php.
DatabaseMssql::nativeInsertSelect | ( | $destTable, | |
$srcTable, | |||
$varMap, | |||
$conds, | |||
$fname = __METHOD__ , |
|||
$insertOptions = [] , |
|||
$selectOptions = [] |
|||
) |
INSERT SELECT wrapper $varMap must be an associative array of the form [ 'dest1' => 'source1', ... ] Source items may be literals rather than field names, but strings should be quoted with Database::addQuotes().
string | $destTable | |
array | string | $srcTable | May be an array of tables. |
array | $varMap | |
array | $conds | May be "*" to copy the whole table. |
string | $fname | |
array | $insertOptions | |
array | $selectOptions |
Exception |
Definition at line 713 of file DatabaseMssql.php.
DatabaseMssql::numFields | ( | $res | ) |
DatabaseMssql::numRows | ( | $res | ) |
DatabaseMssql::open | ( | $server, | |
$user, | |||
$password, | |||
$dbName | |||
) |
Usually aborts on failure.
string | $server | |
string | $user | |
string | $password | |
string | $dbName |
DBConnectionError |
Definition at line 66 of file DatabaseMssql.php.
References $user, $wgDBport, $wgDBWindowsAuthentication, global, and lastError().
|
private |
Definition at line 1284 of file DatabaseMssql.php.
References $res, as, and select().
Referenced by getBinaryColumns(), and getBitColumns().
DatabaseMssql::prepareStatements | ( | $value = null | ) |
Called in the installer and updater.
Probably doesn't need to be called anywhere else in the codebase.
bool | null | $value |
Definition at line 1361 of file DatabaseMssql.php.
References $value, and wfSetVar().
DatabaseMssql::realTableName | ( | $name, | |
$format = 'quoted' |
|||
) |
call this instead of tableName() in the updater when renaming tables
string | $name | |
string | $format | One of quoted, raw, or split |
Definition at line 1324 of file DatabaseMssql.php.
References $name.
Referenced by tableName().
|
protected |
bool | MssqlResultWrapper | resource | $result |
Definition at line 129 of file DatabaseMssql.php.
DatabaseMssql::scrollableCursor | ( | $value = null | ) |
Called in the installer and updater.
Probably doesn't need to be called anywhere else in the codebase.
bool | null | $value |
Definition at line 1371 of file DatabaseMssql.php.
References $value, and wfSetVar().
DatabaseMssql::select | ( | $table, | |
$vars, | |||
$conds = '' , |
|||
$fname = __METHOD__ , |
|||
$options = [] , |
|||
$join_conds = [] |
|||
) |
SELECT wrapper.
mixed | $table | Array or string, table name(s) (prefix auto-added) |
mixed | $vars | Array or string, field name(s) to be retrieved |
mixed | $conds | Array or string, condition(s) for WHERE |
string | $fname | Calling function name (use METHOD) for logs/profiling |
array | $options | Associative array of options (e.g. [ 'GROUP BY' => 'page_title' ]), see Database::makeSelectOptions code for list of supported stuff |
array | $join_conds | Associative array of table join conditions (optional) (e.g. [ 'page' => [ 'LEFT JOIN','page_latest=rev_id' ] ] |
DBQueryError | |
DBUnexpectedError | |
Exception |
Definition at line 371 of file DatabaseMssql.php.
References $fname, $options, $ret, $vars, query, select(), and selectSQLText().
DatabaseMssql::selectDB | ( | $db | ) |
DatabaseMssql::selectSQLText | ( | $table, | |
$vars, | |||
$conds = '' , |
|||
$fname = __METHOD__ , |
|||
$options = [] , |
|||
$join_conds = [] |
|||
) |
SELECT wrapper.
mixed | $table | Array or string, table name(s) (prefix auto-added) |
mixed | $vars | Array or string, field name(s) to be retrieved |
mixed | $conds | Array or string, condition(s) for WHERE |
string | $fname | Calling function name (use METHOD) for logs/profiling |
array | $options | Associative array of options (e.g. [ 'GROUP BY' => 'page_title' ]), see Database::makeSelectOptions code for list of supported stuff |
array | $join_conds | Associative array of table join conditions (optional) (e.g. [ 'page' => [ 'LEFT JOIN','page_latest=rev_id' ] ] |
Definition at line 423 of file DatabaseMssql.php.
References $fname, $options, $t, $vars, as, getBitColumns(), and tableName().
Referenced by buildGroupConcatField(), and select().
DatabaseMssql::strencode | ( | $s | ) |
DatabaseMssql::tableExists | ( | $table, | |
$fname = __METHOD__ |
|||
) |
string | $table | |
string | $fname |
Definition at line 952 of file DatabaseMssql.php.
References $res, $wgDBmwschema, global, list, query, tableName(), and wfDebug().
Referenced by dropTable().
DatabaseMssql::tableName | ( | $name, | |
$format = 'quoted' |
|||
) |
string | $name | |
string | $format |
Definition at line 1308 of file DatabaseMssql.php.
References $name, and realTableName().
DatabaseMssql::textFieldSize | ( | $table, | |
$field | |||
) |
string | $table | |
string | $field |
Definition at line 832 of file DatabaseMssql.php.
References $res, fetchRow(), query, and tableName().
DatabaseMssql::unionSupportsOrderAndLimit | ( | ) |
Definition at line 53 of file DatabaseMssql.php.
DatabaseMssql::update | ( | $table, | |
$values, | |||
$conds, | |||
$fname = __METHOD__ , |
|||
$options = [] |
|||
) |
UPDATE wrapper.
Takes a condition array and a SET array.
string | $table | Name of the table to UPDATE. This will be passed through Database::tableName(). |
array | $values | An array of values to SET. For each array element, the key gives the field name, and the value gives the data to set that field to. The data will be quoted by Database::addQuotes(). |
array | $conds | An array of conditions (WHERE). See Database::select() for the details of the format of condition arrays. Use '*' to update all rows. |
string | $fname | The function name of the caller (from METHOD), for logging and profiling. |
array | $options | An array of UPDATE options, can be:
|
DBUnexpectedError | |
Exception |
Definition at line 761 of file DatabaseMssql.php.
References $e, $options, getBinaryColumns(), LIST_AND, LIST_SET, makeList(), query, and tableName().
|
protected |
Definition at line 34 of file DatabaseMssql.php.
Referenced by affectedRows().
|
protected |
Definition at line 38 of file DatabaseMssql.php.
|
protected |
Definition at line 39 of file DatabaseMssql.php.
|
protected |
Definition at line 40 of file DatabaseMssql.php.
|
protected |
Definition at line 41 of file DatabaseMssql.php.
Referenced by doQuery().
|
protected |
Definition at line 32 of file DatabaseMssql.php.
Referenced by insertId().
|
protected |
Definition at line 33 of file DatabaseMssql.php.
|
protected |
Definition at line 43 of file DatabaseMssql.php.
|
protected |
Definition at line 37 of file DatabaseMssql.php.
|
protected |
Definition at line 36 of file DatabaseMssql.php.
|
protected |
Definition at line 35 of file DatabaseMssql.php.
Referenced by buildGroupConcatField(), and limitResult().