Go to the documentation of this file.
122 throw new MWException(
'The table name needs to be set' );
159 if ( $this->fields ===
array() ) {
160 throw new MWException(
'The table needs to have one or more fields' );
234 $objects[] = $this->
newRow( $record );
267 is_null( $functionName ) ? __METHOD__ : $functionName,
282 is_null( $functionName ) ? __METHOD__ : $functionName
332 $objects = array_map(
'array_shift', $objects );
336 foreach ( $objects
as $object ) {
337 $o[array_shift( $object )] = array_shift( $object );
365 $objects = $this->
select( $fields, $conditions,
$options, $functionName );
367 return ( !$objects || $objects->isEmpty() ) ?
false : $objects->current();
392 is_null( $functionName ) ? __METHOD__ : $functionName,
425 return empty( $objects ) ?
false : $objects[0];
449 public function exists() {
473 array(
'rowcount' =>
'COUNT(*)' ),
479 return $res->rowcount;
492 public function delete(
array $conditions, $functionName = null ) {
498 is_null( $functionName ) ? __METHOD__ : $functionName
516 public function getAPIParams( $requireParams =
false, $setDefaults =
false ) {
531 if ( $field ==
'id' ) {
535 $hasDefault = array_key_exists( $field,
$defaults );
542 if (
$type ==
'array' ) {
546 if ( $setDefaults && $hasDefault ) {
657 parent::releaseConnection( $db );
703 foreach ( $this->
select(
null, $conditions )
as $item ) {
704 $item->loadSummaryFields( $summaryFields );
705 $item->setSummaryMode(
true );
724 $prefixedValues =
array();
726 foreach ( $values
as $field =>
$value ) {
727 if ( is_integer( $field ) ) {
728 if ( is_array(
$value ) ) {
734 $prefixedValues[] = implode(
' ',
$value );
742 return $prefixedValues;
786 return array_map(
array( $this,
'unprefixFieldName' ), $fieldNames );
811 $class = get_called_class();
813 if ( !array_key_exists( $class, self::$instanceCache ) ) {
814 self::$instanceCache[$class] =
new $class;
817 return self::$instanceCache[$class];
834 $rawFields = array_combine(
843 if ( array_key_exists(
$name, $fieldDefinitions ) ) {
844 switch ( $fieldDefinitions[
$name] ) {
852 if ( is_string(
$value ) ) {
854 } elseif ( is_int(
$value ) ) {
859 if ( is_string(
$value ) ) {
863 if ( !is_array(
$value ) ) {
868 if ( is_string(
$value ) ) {
873 if ( is_string(
$value ) ) {
927 return static::newRow( $data, $loadDefaults );
943 return new $class( $this,
$fields, $loadDefaults );
987 is_null( $functionName ) ? __METHOD__ : $functionName
1013 is_null( $functionName ) ? __METHOD__ : $functionName,
1021 $row->
setField(
'id', $dbw->insertId() );
1044 if ( array_key_exists(
$name, $rowFields ) ) {
1076 is_null( $functionName ) ? __METHOD__ : $functionName
1096 if ( !array_key_exists( $field, $this->fields ) ) {
1097 throw new MWException(
'Unknown field "' . $field .
'" provided' );
1100 if ( $amount == 0 ) {
1104 $absoluteAmount = abs( $amount );
1105 $isNegative = $amount < 0;
1113 array(
"$fullField=$fullField" . ( $isNegative ?
'-' :
'+' ) . $absoluteAmount ),
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
getWriteDbConnection()
Get the database type used for read operations.
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
selectFields( $fields=null, array $conditions=array(), array $options=array(), $collapse=true, $functionName=null)
Selects the the specified fields of the records matching the provided conditions and returns them as ...
newRowFromDBResult(stdClass $result)
Get a new instance of the class from a database result.
setReadDb( $db)
Set the database ID to use for read operations, use DB_XXX constants or an index to the load balancer...
getPrefixedValues(array $values)
Takes in an associative array with field names as keys and their values as value.
count(array $conditions=array(), array $options=array())
Returns the amount of matching records.
rawSelectRow(array $fields, array $conditions=array(), array $options=array(), $functionName=null)
Selects the the specified fields of the records matching the provided conditions.
unprefixFieldNames(array $fieldNames)
Takes an array of field names with prefix and returns the unprefixed equivalent.
select( $fields=null, array $conditions=array(), array $options=array(), $functionName=null)
Selects the the specified fields of the records matching the provided conditions and returns them as ...
getPrefixedField( $field)
Takes in a field and returns an it's prefixed version, ready for db usage.
getSummaryFields()
Returns a list of the summary fields.
getTargetWiki()
Get the ID of the any foreign wiki to use as a target for database operations.
getFieldsFromDBResult(stdClass $result)
Get an array with fields from a database result, that can be fed directly to the constructor or to se...
Prior to maintenance scripts were a hodgepodge of code that had no cohesion or formal method of action Beginning maintenance scripts have been cleaned up to use a unified class Directory structure How to run a script How to write your own DIRECTORY STRUCTURE The maintenance directory of a MediaWiki installation contains several all of which have unique purposes HOW TO RUN A SCRIPT Ridiculously just call php someScript php that s in the top level maintenance directory if not default wiki
newFromDBResult(stdClass $result)
getFields()
Return the names and values of the fields.
canHaveField( $name)
Gets if the object can take a certain field.
updateRow(IORMRow $row, $functionName=null)
Updates the provided row in the database.
getDefaults()
Returns a list of default field values.
newFromArray(array $data, $loadDefaults=false)
__construct( $tableName='', array $fields=array(), array $defaults=array(), $rowClass=null, $fieldPrefix='')
Constructor.
releaseConnection(DatabaseBase $db)
Releases the lease on the given database connection.
updateSummaryFields( $summaryFields=null, array $conditions=array())
Computes the values of the summary fields of the objects matching the provided conditions.
setField( $name, $value)
Sets the value of a field.
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
removeRow(IORMRow $row, $functionName=null)
Removes the provided row from the database.
getFieldPrefix()
Gets the db field prefix.
getReadDb()
Get the database ID used for read operations.
update(array $values, array $conditions=array())
Update the records matching the provided conditions by setting the fields that are keys in the $value...
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
selectObjects( $fields=null, array $conditions=array(), array $options=array(), $functionName=null)
Selects the the specified fields of the records matching the provided conditions and returns them as ...
getWriteValues(IORMRow $row)
Gets the fields => values to write to the table.
string bool $wiki
$wiki The target wiki's name.
getReadDbConnection()
Get the database type used for read operations.
processing should stop and the error should be shown to the user * false
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
getPrefixedFields(array $fields)
Takes in a field or array of fields and returns an array with their prefixed versions,...
Allows to change the fields on the form that will be generated $name
selectRow( $fields=null, array $conditions=array(), array $options=array(), $functionName=null)
Selects the the specified fields of the first matching record.
Database abstraction object.
newRow(array $fields, $loadDefaults=false)
Get a new instance of the class from an array.
has(array $conditions=array())
Returns if there is at least one record matching the provided conditions.
integer $readDb
ID of the database connection to use for read operations.
exists()
Checks if the table exists.
getFieldNames()
Return the names of the fields.
getFieldDescriptions()
Returns an array with the fields and their descriptions.
unprefixFieldName( $fieldName)
Takes a field name with prefix and returns the unprefixed equivalent.
rawSelect( $fields=null, array $conditions=array(), array $options=array(), $functionName=null)
Do the actual select.
getAPIParams( $requireParams=false, $setDefaults=false)
Get API parameters for the fields supported by this object.
getId()
Returns the objects database id.
setTargetWiki( $wiki)
Set the ID of the any foreign wiki to use as a target for database operations.
insertRow(IORMRow $row, $functionName=null, array $options=null)
Inserts the provided row into the database.
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
getConnection( $id, $groups=array())
Returns a database connection.
selectFieldsRow( $fields=null, array $conditions=array(), array $options=array(), $collapse=true, $functionName=null)
Selects the the specified fields of the first record matching the provided conditions and returns it ...
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string as detected by MediaWiki Handlers will typically only apply for specific mime types object & $error
addToField(array $conditions, $field, $amount)
Add an amount (can be negative) to the specified field (needs to be numeric).
static singleton()
Get an instance of this class.