MediaWiki  1.34.0
TitleArrayFromResult.php
Go to the documentation of this file.
1 <?php
28 
29 class TitleArrayFromResult extends TitleArray implements Countable {
31  public $res;
32 
33  public $key;
34 
35  public $current;
36 
37  function __construct( $res ) {
38  $this->res = $res;
39  $this->key = 0;
40  $this->setCurrent( $this->res->current() );
41  }
42 
47  protected function setCurrent( $row ) {
48  if ( $row === false ) {
49  $this->current = false;
50  } else {
51  $this->current = Title::newFromRow( $row );
52  }
53  }
54 
58  public function count() {
59  return $this->res->numRows();
60  }
61 
62  function current() {
63  return $this->current;
64  }
65 
66  function key() {
67  return $this->key;
68  }
69 
70  function next() {
71  $row = $this->res->next();
72  $this->setCurrent( $row );
73  $this->key++;
74  }
75 
76  function rewind() {
77  $this->res->rewind();
78  $this->key = 0;
79  $this->setCurrent( $this->res->current() );
80  }
81 
85  function valid() {
86  return $this->current !== false;
87  }
88 }
TitleArrayFromResult\current
current()
Definition: TitleArrayFromResult.php:62
TitleArrayFromResult\setCurrent
setCurrent( $row)
Definition: TitleArrayFromResult.php:47
TitleArrayFromResult\$current
$current
Definition: TitleArrayFromResult.php:35
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
Title\newFromRow
static newFromRow( $row)
Make a Title object from a DB row.
Definition: Title.php:518
TitleArrayFromResult
Definition: TitleArrayFromResult.php:29
TitleArrayFromResult\next
next()
Definition: TitleArrayFromResult.php:70
TitleArrayFromResult\count
count()
Definition: TitleArrayFromResult.php:58
TitleArrayFromResult\key
key()
Definition: TitleArrayFromResult.php:66
TitleArrayFromResult\__construct
__construct( $res)
Definition: TitleArrayFromResult.php:37
TitleArrayFromResult\rewind
rewind()
Definition: TitleArrayFromResult.php:76
TitleArrayFromResult\$key
$key
Definition: TitleArrayFromResult.php:33
TitleArrayFromResult\$res
IResultWrapper $res
Definition: TitleArrayFromResult.php:31
TitleArray
The TitleArray class only exists to provide the newFromResult method at pre- sent.
Definition: TitleArray.php:35
TitleArrayFromResult\valid
valid()
Definition: TitleArrayFromResult.php:85