Go to the documentation of this file.
86 # Test for driver support, to avoid suppressed fatal error
87 if ( !function_exists(
'sqlsrv_connect' ) ) {
90 "Microsoft SQL Server Native (sqlsrv) functions missing.
91 You can download the driver from: http://go.microsoft.com/fwlink/?LinkId=123470\n"
95 global $wgDBport, $wgDBWindowsAuthentication;
97 # e.g. the class is being loaded
98 if ( !strlen(
$user ) ) {
103 $this->mServer = $server;
104 $this->mPort = $wgDBport;
105 $this->mUser =
$user;
107 $this->mDBname = $dbName;
109 $connectionInfo =
array();
112 $connectionInfo[
'Database'] = $dbName;
117 if ( !$wgDBWindowsAuthentication ) {
118 $connectionInfo[
'UID'] =
$user;
123 $this->mConn = sqlsrv_connect( $server, $connectionInfo );
126 if ( $this->mConn ===
false ) {
130 $this->mOpened =
true;
141 return sqlsrv_close( $this->mConn );
153 } elseif (
$result ===
true ) {
167 if ( $this->
debug() ) {
177 if ( preg_match(
'/\bLIMIT\s*/i', $sql ) ) {
183 if ( preg_match(
'#\bEXTRACT\s*?\(\s*?EPOCH\s+FROM\b#i', $sql,
$matches ) ) {
185 $sql = str_replace(
$matches[0],
"DATEDIFF(s,CONVERT(datetime,'1/1/1970'),", $sql );
194 if ( $this->mScrollableCursor ) {
195 $scrollArr =
array(
'Scrollable' => SQLSRV_CURSOR_STATIC );
197 $scrollArr =
array();
200 if ( $this->mPrepareStatements ) {
202 $stmt = sqlsrv_prepare( $this->mConn, $sql,
array(), $scrollArr );
205 $stmt = sqlsrv_query( $this->mConn, $sql,
array(), $scrollArr );
209 if ( $this->mIgnoreDupKeyErrors ) {
213 $errors = sqlsrv_errors( SQLSRV_ERR_ERRORS );
216 foreach ( $errors
as $err ) {
217 if ( $err[
'SQLSTATE'] ==
'23000' && $err[
'code'] ==
'2601' ) {
219 } elseif ( $err[
'SQLSTATE'] ==
'23000' && $err[
'code'] ==
'2627' ) {
221 } elseif ( $err[
'SQLSTATE'] ==
'01000' && $err[
'code'] ==
'3621' ) {
230 $this->mAffectedRows = 0;
240 $this->mAffectedRows = sqlsrv_rows_affected( $stmt );
250 sqlsrv_free_stmt(
$res );
259 return $res->fetchObject();
267 return $res->fetchRow();
279 return sqlsrv_num_rows(
$res );
291 return sqlsrv_num_fields(
$res );
304 $metadata = sqlsrv_field_metadata(
$res );
305 return $metadata[
$n][
'Name'];
322 return $res->seek( $row );
330 $retErrors = sqlsrv_errors( SQLSRV_ERR_ALL );
331 if ( $retErrors !=
null ) {
332 foreach ( $retErrors
as $arrError ) {
336 $strRet =
"No errors found";
346 return '[SQLSTATE ' . $err[
'SQLSTATE'] .
'][Error Code ' . $err[
'code'] .
']' . $err[
'message'];
353 $err = sqlsrv_errors( SQLSRV_ERR_ALL );
354 if ( $err !==
null && isset( $err[0] ) ) {
355 return $err[0][
'code'];
387 if ( isset(
$options[
'EXPLAIN'] ) ) {
389 $this->mScrollableCursor =
false;
390 $this->mPrepareStatements =
false;
391 $this->
query(
"SET SHOWPLAN_ALL ON" );
393 $this->
query(
"SET SHOWPLAN_ALL OFF" );
395 if ( isset(
$options[
'FOR COUNT'] ) ) {
397 $this->
query(
"SET SHOWPLAN_ALL OFF" );
401 'COUNT(*) AS EstimateRows',
410 $this->mScrollableCursor =
true;
411 $this->mPrepareStatements =
true;
415 $this->mScrollableCursor =
true;
416 $this->mPrepareStatements =
true;
440 if ( isset(
$options[
'EXPLAIN'] ) ) {
447 if ( strpos( $sql,
'MAX(' ) !==
false || strpos( $sql,
'MIN(' ) !==
false ) {
448 $bitColumns =
array();
449 if ( is_array( $table ) ) {
450 foreach ( $table
as $t ) {
457 foreach ( $bitColumns
as $col => $info ) {
459 "MAX({$col})" =>
"MAX(CAST({$col} AS tinyint))",
460 "MIN({$col})" =>
"MIN(CAST({$col} AS tinyint))",
462 $sql = str_replace( array_keys( $replace ), array_values( $replace ), $sql );
469 public function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds,
472 $this->mScrollableCursor =
false;
474 parent::deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds,
$fname );
475 }
catch ( Exception
$e ) {
476 $this->mScrollableCursor =
true;
479 $this->mScrollableCursor =
true;
482 public function delete( $table, $conds,
$fname = __METHOD__ ) {
483 $this->mScrollableCursor =
false;
485 parent::delete( $table, $conds,
$fname );
486 }
catch ( Exception
$e ) {
487 $this->mScrollableCursor =
true;
490 $this->mScrollableCursor =
true;
518 if ( isset( $row[
'EstimateRows'] ) ) {
519 $rows = $row[
'EstimateRows'];
535 # This does not return the same info as MYSQL would, but that's OK
536 # because MediaWiki never uses the returned value except to check for
537 # the existance of indexes.
538 $sql =
"sp_helpindex '" . $table .
"'";
545 foreach (
$res as $row ) {
546 if ( $row->index_name == $index ) {
547 $row->Non_unique = !stristr( $row->index_description,
"unique" );
548 $cols = explode(
", ", $row->index_keys );
549 foreach ( $cols
as $col ) {
550 $row->Column_name = trim( $col );
553 } elseif ( $index ==
'PRIMARY' && stristr( $row->index_description,
'PRIMARY' ) ) {
554 $row->Non_unique = 0;
555 $cols = explode(
", ", $row->index_keys );
556 foreach ( $cols
as $col ) {
557 $row->Column_name = trim( $col );
582 # No rows to insert, easy just return now
583 if ( !count( $arrToInsert ) ) {
593 if ( !( isset( $arrToInsert[0] ) && is_array( $arrToInsert[0] ) ) ) {
594 $arrToInsert =
array( 0 => $arrToInsert );
600 $tableRawArr = explode(
'.', preg_replace(
'#\[([^\]]*)\]#',
'$1', $table ) );
601 $tableRaw = array_pop( $tableRawArr );
603 "SELECT NAME AS idColumn FROM SYS.IDENTITY_COLUMNS " .
604 "WHERE OBJECT_NAME(OBJECT_ID)='{$tableRaw}'"
606 if (
$res && sqlsrv_has_rows(
$res ) ) {
608 $identityArr = sqlsrv_fetch_array(
$res, SQLSRV_FETCH_ASSOC );
609 $identity = array_pop( $identityArr );
611 sqlsrv_free_stmt(
$res );
616 foreach ( $arrToInsert
as $a ) {
621 $identityClause =
'';
626 foreach ( $a
as $k => $v ) {
627 if ( $k == $identity ) {
628 if ( !is_null( $v ) ) {
631 $sqlPre =
"SET IDENTITY_INSERT $table ON;";
632 $sqlPost =
";SET IDENTITY_INSERT $table OFF;";
642 $identityClause =
"OUTPUT INSERTED.$identity ";
645 $keys = array_keys( $a );
649 $ignoreClause =
false;
650 if ( in_array(
'IGNORE',
$options ) ) {
652 $this->mIgnoreDupKeyErrors =
true;
656 $sql = $sqlPre .
'INSERT ' . implode(
' ',
$options ) .
657 " INTO $table (" . implode(
',',
$keys ) .
") $identityClause VALUES (";
661 if ( isset( $binaryColumns[$key] ) ) {
669 if ( is_null(
$value ) ) {
671 } elseif ( is_array(
$value ) || is_object(
$value ) ) {
681 $sql .=
')' . $sqlPost;
684 $this->mScrollableCursor =
false;
687 }
catch ( Exception
$e ) {
688 $this->mScrollableCursor =
true;
689 $this->mIgnoreDupKeyErrors =
false;
692 $this->mScrollableCursor =
true;
693 $this->mIgnoreDupKeyErrors =
false;
695 if ( !is_null( $identity ) ) {
697 $row =
$ret->fetchObject();
698 $this->mInsertId = $row->$identity;
721 $insertOptions =
array(), $selectOptions =
array()
723 $this->mScrollableCursor =
false;
725 $ret = parent::insertSelect(
734 }
catch ( Exception
$e ) {
735 $this->mScrollableCursor =
true;
738 $this->mScrollableCursor =
true;
771 $sql =
"UPDATE $opts $table SET " . $this->
makeList( $values,
LIST_SET, $binaryColumns );
773 if ( $conds !==
array() && $conds !==
'*' ) {
777 $this->mScrollableCursor =
false;
780 }
catch ( Exception
$e ) {
781 $this->mScrollableCursor =
true;
784 $this->mScrollableCursor =
true;
805 if ( !is_array( $a ) ) {
807 'DatabaseBase::makeList called with incorrect parameters' );
813 foreach ( $a
as $field =>
$value ) {
814 if ( $mode !=
LIST_NAMES && isset( $binaryColumns[$field] ) ) {
815 if ( is_array(
$value ) ) {
827 } elseif ( $mode ==
LIST_OR ) {
836 if ( ( $mode ==
LIST_AND || $mode ==
LIST_OR ) && is_numeric( $field ) ) {
838 } elseif ( ( $mode ==
LIST_SET ) && is_numeric( $field ) ) {
841 if ( count(
$value ) == 0 ) {
842 throw new MWException( __METHOD__ .
": empty input for field $field" );
843 } elseif ( count(
$value ) == 1 ) {
852 } elseif (
$value ===
null ) {
854 $list .=
"$field IS ";
856 $list .=
"$field = ";
861 $list .=
"$field = ";
877 $sql =
"SELECT CHARACTER_MAXIMUM_LENGTH,DATA_TYPE FROM INFORMATION_SCHEMA.Columns
878 WHERE TABLE_NAME = '$table' AND COLUMN_NAME = '$field'";
882 if ( strtolower( $row[
'DATA_TYPE'] ) !=
'text' ) {
883 $size = $row[
'CHARACTER_MAXIMUM_LENGTH'];
899 if ( $offset ===
false || $offset == 0 ) {
900 if ( strpos( $sql,
"SELECT" ) ===
false ) {
901 return "TOP {$limit} " . $sql;
903 return preg_replace(
'/\bSELECT(\s+DISTINCT)?\b/Dsi',
904 'SELECT$1 TOP ' .
$limit, $sql, 1 );
908 $select = $orderby =
array();
909 $s1 = preg_match(
'#SELECT\s+(.+?)\s+FROM#Dis', $sql, $select );
910 $s2 = preg_match(
'#(ORDER BY\s+.+?)(\s*FOR XML .*)?$#Dis', $sql, $orderby );
911 $overOrder = $postOrder =
'';
912 $first = $offset + 1;
915 $sub2 =
'sub_' . ( $this->mSubqueryId + 1 );
916 $this->mSubqueryId += 2;
919 throw new DBUnexpectedError( $this,
"Attempting to LIMIT a non-SELECT query\n" );
923 $overOrder =
'ORDER BY 1';
925 if ( !isset( $orderby[2] ) || !$orderby[2] ) {
927 $sql = str_replace( $orderby[1],
'', $sql );
929 $overOrder = $orderby[1];
930 $postOrder =
' ' . $overOrder;
932 $sql =
"SELECT {$select[1]}
934 SELECT ROW_NUMBER() OVER({$overOrder}) AS rowNumber, *
935 FROM ({$sql}) {$sub1}
937 WHERE rowNumber BETWEEN {$first} AND {$last}{$postOrder}";
955 $pattern =
'/\bLIMIT\s+((([0-9]+)\s*,\s*)?([0-9]+)(\s+OFFSET\s+([0-9]+))?)/i';
956 if ( preg_match( $pattern, $sql,
$matches ) ) {
965 $sql = str_replace(
$matches[0],
'', $sql );
967 return $this->
limitResult( $sql, $row_count, $offset );
977 return "[{{int:version-db-mssql-url}} MS SQL Server]";
984 $server_info = sqlsrv_server_info( $this->mConn );
986 if ( isset( $server_info[
'SQLServerVersion'] ) ) {
987 $version = $server_info[
'SQLServerVersion'];
999 list( $db, $schema, $table ) = $this->
tableName( $table,
'split' );
1001 if ( $db !==
false ) {
1003 wfDebug(
"Attempting to call tableExists on a remote table" );
1007 $res = $this->
query(
"SELECT 1 FROM INFORMATION_SCHEMA.TABLES
1008 WHERE TABLE_TYPE = 'BASE TABLE'
1009 AND TABLE_SCHEMA = '$schema' AND TABLE_NAME = '$table'" );
1011 if (
$res->numRows() ) {
1026 list( $db, $schema, $table ) = $this->
tableName( $table,
'split' );
1028 if ( $db !==
false ) {
1030 wfDebug(
"Attempting to call fieldExists on a remote table" );
1034 $res = $this->
query(
"SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
1035 WHERE TABLE_SCHEMA = '$schema' AND TABLE_NAME = '$table' AND COLUMN_NAME = '$field'" );
1037 if (
$res->numRows() ) {
1045 list( $db, $schema, $table ) = $this->
tableName( $table,
'split' );
1047 if ( $db !==
false ) {
1049 wfDebug(
"Attempting to call fieldInfo on a remote table" );
1053 $res = $this->
query(
"SELECT * FROM INFORMATION_SCHEMA.COLUMNS
1054 WHERE TABLE_SCHEMA = '$schema' AND TABLE_NAME = '$table' AND COLUMN_NAME = '$field'" );
1056 $meta =
$res->fetchRow();
1068 sqlsrv_begin_transaction( $this->mConn );
1069 $this->mTrxLevel = 1;
1076 sqlsrv_commit( $this->mConn );
1077 $this->mTrxLevel = 0;
1085 sqlsrv_rollback( $this->mConn );
1086 $this->mTrxLevel = 0;
1098 if ( strlen( $identifier ) == 0 ) {
1099 throw new MWException(
"An identifier must not be empty" );
1101 if ( strlen( $identifier ) > 128 ) {
1102 throw new MWException(
"The identifier '$identifier' is too long (max. 128)" );
1104 if ( ( strpos( $identifier,
'[' ) !==
false )
1105 || ( strpos( $identifier,
']' ) !==
false )
1109 throw new MWException(
"Square brackets are not allowed in '$identifier'" );
1112 return "[$identifier]";
1120 return str_replace(
"'",
"''",
$s );
1130 } elseif (
$s instanceof
Blob ) {
1134 return $blob->fetch();
1136 if ( is_bool(
$s ) ) {
1139 return parent::addQuotes(
$s );
1149 return '[' .
$s .
']';
1157 return strlen(
$name ) &&
$name[0] ==
'[' && substr(
$name, -1, 1 ) ==
']';
1166 $this->mDBname = $db;
1167 $this->
query(
"USE $db" );
1169 }
catch ( Exception
$e ) {
1183 $noKeyOptions =
array();
1185 if ( is_numeric( $key ) ) {
1186 $noKeyOptions[$option] =
true;
1194 if ( isset( $noKeyOptions[
'DISTINCT'] ) || isset( $noKeyOptions[
'DISTINCTROW'] ) ) {
1195 $startOpts .=
'DISTINCT';
1198 if ( isset( $noKeyOptions[
'FOR XML'] ) ) {
1200 $tailOpts .=
" FOR XML PATH('')";
1204 return array( $startOpts,
'', $tailOpts,
'' );
1220 return implode(
' + ', $stringList );
1241 $join_conds =
array()
1244 $this->mSubqueryId++;
1246 $delimLen = strlen( $delim );
1247 $fld =
"{$field} + {$this->addQuotes( $delim )}";
1248 $sql =
"(SELECT LEFT({$field}, LEN({$field}) - {$delimLen}) FROM ("
1249 . $this->
selectSQLText( $table, $fld, $conds,
null,
array(
'FOR XML' ), $join_conds )
1250 .
") {$gcsq} ({$field}))";
1259 return "SearchMssql";
1269 $tableRawArr = explode(
'.', preg_replace(
'#\[([^\]]*)\]#',
'$1', $table ) );
1270 $tableRaw = array_pop( $tableRawArr );
1272 if ( $this->mBinaryColumnCache ===
null ) {
1276 return isset( $this->mBinaryColumnCache[$tableRaw] )
1277 ? $this->mBinaryColumnCache[$tableRaw]
1286 $tableRawArr = explode(
'.', preg_replace(
'#\[([^\]]*)\]#',
'$1', $table ) );
1287 $tableRaw = array_pop( $tableRawArr );
1289 if ( $this->mBitColumnCache ===
null ) {
1293 return isset( $this->mBitColumnCache[$tableRaw] )
1294 ? $this->mBitColumnCache[$tableRaw]
1302 $res = $this->
select(
'INFORMATION_SCHEMA.COLUMNS',
'*',
1304 'TABLE_CATALOG' => $this->mDBname,
1305 'TABLE_SCHEMA' => $this->mSchema,
1306 'DATA_TYPE' =>
array(
'varbinary',
'binary',
'image',
'bit' )
1309 $this->mBinaryColumnCache =
array();
1310 $this->mBitColumnCache =
array();
1311 foreach (
$res as $row ) {
1312 if ( $row->DATA_TYPE ==
'bit' ) {
1313 $this->mBitColumnCache[$row->TABLE_NAME][$row->COLUMN_NAME] = $row;
1315 $this->mBinaryColumnCache[$row->TABLE_NAME][$row->COLUMN_NAME] = $row;
1326 # Replace reserved words with better ones
1343 if ( $format ==
'split' ) {
1346 $table = explode(
'.', $table );
1347 if ( count( $table ) == 2 ) {
1348 array_unshift( $table,
false );
1384 $this->
name = $info[
'COLUMN_NAME'];
1386 $this->
default = $info[
'COLUMN_DEFAULT'];
1387 $this->max_length = $info[
'CHARACTER_MAXIMUM_LENGTH'];
1388 $this->nullable = !( strtolower( $info[
'IS_NULLABLE'] ) ==
'no' );
1389 $this->
type = $info[
'DATA_TYPE'];
1421 } elseif ( $data instanceof
Blob ) {
1422 $this->mData = $data->fetch();
1423 } elseif ( is_array( $data ) && is_object( $data ) ) {
1424 $this->mData = serialize( $data );
1426 $this->mData = $data;
1436 if ( $this->mData ===
null ) {
1441 $dataLength = strlen( $this->mData );
1442 for ( $i = 0; $i < $dataLength; $i++ ) {
1443 $ret .= bin2hex( pack(
'C', ord( $this->mData[$i] ) ) );
1459 if ( $this->mSeekTo !==
null ) {
1461 SQLSRV_SCROLL_ABSOLUTE, $this->mSeekTo );
1462 $this->mSeekTo =
null;
1481 if ( $this->mSeekTo !==
null ) {
1482 $result = sqlsrv_fetch_array(
$res, SQLSRV_FETCH_BOTH,
1483 SQLSRV_SCROLL_ABSOLUTE, $this->mSeekTo );
1484 $this->mSeekTo =
null;
1505 $numRows = $this->db->numRows(
$res );
1506 $row = intval( $row );
1508 if ( $numRows === 0 ) {
1510 } elseif ( $row < 0 || $row > $numRows - 1 ) {
1515 $this->mSeekTo = $row;
textFieldSize( $table, $field)
strictIPs()
Returns true if this database is strict about what can be put into an IP field.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
populateColumnCaches()
@void
escapeIdentifier( $identifier)
Escapes a identifier for use inm SQL.
tableName()
Name of table this field belongs to.
debug( $debug=null)
Boolean, controls output of large amounts of debug information.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
makeList( $a, $mode=LIST_COMMA, $binaryColumns=array())
Makes an encoded list of strings from an array.
open( $server, $user, $password, $dbName)
Usually aborts on failure.
cleanupTriggers()
Returns true if this database supports (and uses) triggers (e.g.
implicitOrderby()
Returns true if this database does an implicit order by when the column has an index For example: SEL...
estimateRowCount( $table, $vars=' *', $conds='', $fname=__METHOD__, $options=array())
Estimate rows in dataset Returns estimated count, based on SHOWPLAN_ALL output This is not necessaril...
Base for all database-specific classes representing information about database fields.
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
makeUpdateOptions( $options)
Make UPDATE options for the DatabaseBase::update function.
close()
Closes a database connection.
query( $sql, $fname=__METHOD__, $tempIgnore=false)
Run an SQL query and return the result.
realTableName( $name, $format='quoted')
call this instead of tableName() in the updater when renaming tables
insertId()
This must be called after nextSequenceVal.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
buildGroupConcatField( $delim, $table, $field, $conds='', $join_conds=array())
Build a GROUP_CONCAT or equivalent statement for a query.
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
makeOrderBy( $options)
Returns an optional ORDER BY.
select( $table, $vars, $conds='', $fname=__METHOD__, $options=array(), $join_conds=array())
SELECT wrapper.
closeConnection()
Closes a database connection, if it is open Returns success, true if already closed.
fetch()
Returns an unquoted hex representation of a binary string for insertion into varbinary-type fields.
selectSQLText( $table, $vars, $conds='', $fname=__METHOD__, $options=array(), $join_conds=array())
SELECT wrapper.
doBegin( $fname=__METHOD__)
Begin a transaction, committing any previously open transaction.
resource $mConn
Database connection *.
tableExists( $table, $fname=__METHOD__)
wfRestoreWarnings()
Restore error level to previous value.
getBinaryColumns( $table)
Returns an associative array for fields that are of type varbinary, binary, or image $table can be ei...
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like please read the documentation for tableName() and addQuotes(). You will need both of them. ------------------------------------------------------------------------ Basic query optimisation ------------------------------------------------------------------------ MediaWiki developers who need to write DB queries should have some understanding of databases and the performance issues associated with them. Patches containing unacceptably slow features will not be accepted. Unindexed queries are generally not welcome in MediaWiki
prepareStatements( $value=null)
Called in the installer and updater.
implicitGroupby()
Returns true if this database does an implicit sort when doing GROUP BY.
insert( $table, $arrToInsert, $fname=__METHOD__, $options=array())
INSERT wrapper, inserts an array into a table.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
isQuotedIdentifier( $name)
fieldInfo( $table, $field)
mysql_fetch_field() wrapper Returns false if the field doesn't exist
doCommit( $fname=__METHOD__)
End a transaction.
when a variable name is used in a it is silently declared as a new masking the global
cascadingDeletes()
Returns true if this database supports (and uses) cascading deletes.
tableName( $name, $format='quoted')
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
processing should stop and the error should be shown to the user * false
getType()
Get the type of the DBMS, as it appears in $wgDBtype.
makeGroupByWithHaving( $options)
Returns an optional GROUP BY with an optional HAVING.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Allows to change the fields on the form that will be generated $name
if(!defined( 'MEDIAWIKI')) if(!isset( $wgVersion)) $matches
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',...
isNullable()
Whether this field can store NULL values.
Database abstraction object.
functionalIndexes()
Returns true if this database can use functional indexes.
fieldExists( $table, $field, $fname=__METHOD__)
Query whether a given column exists in the mediawiki schema.
makeSelectOptions( $options)
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks this Boolean value will be checked to determine if the password was valid return false to implement your own hashing method & $password
indexInfo( $table, $index, $fname=__METHOD__)
Returns information about an index If errors are explicitly ignored, returns NULL on failure.
deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname=__METHOD__)
DELETE where the condition is a join.
update( $table, $values, $conds, $fname=__METHOD__, $options=array())
UPDATE wrapper.
freeResult( $res)
Free a result object returned by query() or select().
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
buildConcat( $stringList)
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
unionSupportsOrderAndLimit()
Returns true if current database backend supports ORDER BY or LIMIT for separate subqueries within th...
LimitToTopN( $sql)
If there is a limit clause, parse it, strip it, and pass the remaining SQL through limitResult() with...
doRollback( $fname=__METHOD__)
Rollback a transaction.
limitResult( $sql, $limit, $offset=false)
Construct a LIMIT query with optional offset This is used for query pages.
realTimestamps()
Returns true if this database uses timestamps rather than integers.
Result wrapper for grabbing data queried by someone else.
scrollableCursor( $value=null)
Called in the installer and updater.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e