MediaWiki  1.23.2
DatabaseUtility.php
Go to the documentation of this file.
1 <?php
28 class DBObject {
29  public $mData;
30 
31  function __construct( $data ) {
32  $this->mData = $data;
33  }
34 
38  function isLOB() {
39  return false;
40  }
41 
42  function data() {
43  return $this->mData;
44  }
45 }
46 
53 class Blob {
55  protected $mData;
56 
57  function __construct( $data ) {
58  $this->mData = $data;
59  }
60 
61  function fetch() {
62  return $this->mData;
63  }
64 }
65 
70 interface Field {
75  function name();
76 
81  function tableName();
82 
87  function type();
88 
93  function isNullable();
94 }
95 
100 class ResultWrapper implements Iterator {
102  public $result;
103 
105  protected $db;
106 
108  protected $pos = 0;
109 
111  protected $currentRow = null;
112 
119  function __construct( $database, $result ) {
120  $this->db = $database;
121 
122  if ( $result instanceof ResultWrapper ) {
123  $this->result = $result->result;
124  } else {
125  $this->result = $result;
126  }
127  }
128 
134  function numRows() {
135  return $this->db->numRows( $this );
136  }
137 
146  function fetchObject() {
147  return $this->db->fetchObject( $this );
148  }
149 
157  function fetchRow() {
158  return $this->db->fetchRow( $this );
159  }
160 
164  function free() {
165  $this->db->freeResult( $this );
166  unset( $this->result );
167  unset( $this->db );
168  }
169 
176  function seek( $row ) {
177  $this->db->dataSeek( $this, $row );
178  }
179 
180  /*********************
181  * Iterator functions
182  * Note that using these in combination with the non-iterator functions
183  * above may cause rows to be skipped or repeated.
184  */
185 
186  function rewind() {
187  if ( $this->numRows() ) {
188  $this->db->dataSeek( $this, 0 );
189  }
190  $this->pos = 0;
191  $this->currentRow = null;
192  }
193 
197  function current() {
198  if ( is_null( $this->currentRow ) ) {
199  $this->next();
200  }
201 
202  return $this->currentRow;
203  }
204 
208  function key() {
209  return $this->pos;
210  }
211 
215  function next() {
216  $this->pos++;
217  $this->currentRow = $this->fetchObject();
218 
219  return $this->currentRow;
220  }
221 
225  function valid() {
226  return $this->current() !== false;
227  }
228 }
229 
234 class FakeResultWrapper extends ResultWrapper {
236  public $result = array();
237 
239  protected $db = null;
240 
242  protected $pos = 0;
243 
245  protected $currentRow = null;
246 
247  function __construct( $array ) {
248  $this->result = $array;
249  }
250 
254  function numRows() {
255  return count( $this->result );
256  }
257 
258  function fetchRow() {
259  if ( $this->pos < count( $this->result ) ) {
260  $this->currentRow = $this->result[$this->pos];
261  } else {
262  $this->currentRow = false;
263  }
264  $this->pos++;
265  if ( is_object( $this->currentRow ) ) {
266  return get_object_vars( $this->currentRow );
267  } else {
269  }
270  }
271 
272  function seek( $row ) {
273  $this->pos = $row;
274  }
275 
276  function free() {
277  }
278 
279  // Callers want to be able to access fields with $this->fieldName
280  function fetchObject() {
281  $this->fetchRow();
282  if ( $this->currentRow ) {
283  return (object)$this->currentRow;
284  } else {
285  return false;
286  }
287  }
288 
289  function rewind() {
290  $this->pos = 0;
291  $this->currentRow = null;
292  }
293 
294  function next() {
295  return $this->fetchObject();
296  }
297 }
298 
304 class LikeMatch {
306  private $str;
307 
313  public function __construct( $s ) {
314  $this->str = $s;
315  }
316 
322  public function toString() {
323  return $this->str;
324  }
325 }
326 
332 interface DBMasterPos {
333 }
DBObject\$mData
$mData
Definition: DatabaseUtility.php:29
ResultWrapper\__construct
__construct( $database, $result)
Create a new result object from a result resource and a Database object.
Definition: DatabaseUtility.php:115
Blob\fetch
fetch()
Definition: DatabaseUtility.php:60
FakeResultWrapper
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
Definition: DatabaseUtility.php:230
LikeMatch\toString
toString()
Return the original stored string.
Definition: DatabaseUtility.php:313
$result
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
Definition: hooks.txt:1528
LikeMatch\__construct
__construct( $s)
Store a string into a LikeMatch marker object.
Definition: DatabaseUtility.php:304
php
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
Definition: skin.txt:62
DBObject\data
data()
Definition: DatabaseUtility.php:42
Field
Base for all database-specific classes representing information about database fields.
Definition: DatabaseUtility.php:69
ResultWrapper\key
key()
Definition: DatabaseUtility.php:203
Field\tableName
tableName()
Name of table this field belongs to.
DBObject\__construct
__construct( $data)
Definition: DatabaseUtility.php:31
ResultWrapper\numRows
numRows()
Get the number of rows in a result object.
Definition: DatabaseUtility.php:130
FakeResultWrapper\$currentRow
array stdClass bool $currentRow
Definition: DatabaseUtility.php:237
FakeResultWrapper\seek
seek( $row)
Change the position of the cursor in a result object.
Definition: DatabaseUtility.php:264
Blob
Utility class.
Definition: DatabaseUtility.php:53
$s
$s
Definition: mergeMessageFileList.php:156
Field\isNullable
isNullable()
Whether this field can store NULL values.
DBMasterPos
An object representing a master or slave position in a replicated setup.
Definition: DatabaseUtility.php:323
ResultWrapper\$currentRow
$currentRow
Definition: DatabaseUtility.php:107
FakeResultWrapper\next
next()
Definition: DatabaseUtility.php:286
LikeMatch
Used by DatabaseBase::buildLike() to represent characters that have special meaning in SQL LIKE claus...
Definition: DatabaseUtility.php:296
FakeResultWrapper\numRows
numRows()
Definition: DatabaseUtility.php:246
FakeResultWrapper\rewind
rewind()
Definition: DatabaseUtility.php:281
ResultWrapper\free
free()
Free a result object.
Definition: DatabaseUtility.php:160
FakeResultWrapper\$db
null $db
And it's going to stay that way :D *.
Definition: DatabaseUtility.php:233
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
DBObject
Utility class.
Definition: DatabaseUtility.php:28
ResultWrapper\fetchRow
fetchRow()
Fetch the next row from the given result object, in associative array form.
Definition: DatabaseUtility.php:153
ResultWrapper\$pos
int $pos
Definition: DatabaseUtility.php:104
ResultWrapper\$db
DatabaseBase $db
Definition: DatabaseUtility.php:102
DatabaseBase
Database abstraction object.
Definition: Database.php:219
FakeResultWrapper\fetchObject
fetchObject()
Fetch the next row from the given result object, in object form.
Definition: DatabaseUtility.php:272
ResultWrapper\$result
resource $result
Definition: DatabaseUtility.php:100
ResultWrapper\rewind
rewind()
Definition: DatabaseUtility.php:181
Field\type
type()
Database type.
ResultWrapper\next
next()
Definition: DatabaseUtility.php:210
LikeMatch\$str
string $str
Definition: DatabaseUtility.php:297
ResultWrapper\seek
seek( $row)
Change the position of the cursor in a result object.
Definition: DatabaseUtility.php:172
FakeResultWrapper\$pos
int $pos
Definition: DatabaseUtility.php:235
DBObject\isLOB
isLOB()
Definition: DatabaseUtility.php:38
FakeResultWrapper\__construct
__construct( $array)
Definition: DatabaseUtility.php:239
Field\name
name()
Field name.
FakeResultWrapper\fetchRow
fetchRow()
Fetch the next row from the given result object, in associative array form.
Definition: DatabaseUtility.php:250
FakeResultWrapper\free
free()
Free a result object.
Definition: DatabaseUtility.php:268
ResultWrapper\fetchObject
fetchObject()
Fetch the next row from the given result object, in object form.
Definition: DatabaseUtility.php:142
ResultWrapper\valid
valid()
Definition: DatabaseUtility.php:220
Blob\__construct
__construct( $data)
Definition: DatabaseUtility.php:56
Blob\$mData
string $mData
Definition: DatabaseUtility.php:54
ResultWrapper\current
current()
Definition: DatabaseUtility.php:192
ResultWrapper
Result wrapper for grabbing data queried by someone else.
Definition: DatabaseUtility.php:99