MediaWiki  master
TitleArrayFromResult.php
Go to the documentation of this file.
1 <?php
28 
34 class TitleArrayFromResult extends TitleArray implements Countable {
36  public $res;
37 
38  public $key;
39 
40  public $current;
41 
47  public function __construct( $res ) {
48  $this->res = $res;
49  $this->key = 0;
50  $this->setCurrent( $this->res->current() );
51  }
52 
57  protected function setCurrent( $row ) {
58  if ( $row === false ) {
59  $this->current = false;
60  } else {
61  $this->current = Title::newFromRow( $row );
62  }
63  }
64 
68  public function count() {
69  return $this->res->numRows();
70  }
71 
72  public function current() {
73  return $this->current;
74  }
75 
76  public function key() {
77  return $this->key;
78  }
79 
80  public function next() {
81  $row = $this->res->next();
82  $this->setCurrent( $row );
83  $this->key++;
84  }
85 
86  public function rewind() {
87  $this->res->rewind();
88  $this->key = 0;
89  $this->setCurrent( $this->res->current() );
90  }
91 
95  public function valid() {
96  return $this->current !== false;
97  }
98 }
TitleArrayFromResult\current
current()
Definition: TitleArrayFromResult.php:72
TitleArrayFromResult\setCurrent
setCurrent( $row)
Definition: TitleArrayFromResult.php:57
TitleArrayFromResult\$current
$current
Definition: TitleArrayFromResult.php:40
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:524
TitleArrayFromResult
@newable
Definition: TitleArrayFromResult.php:34
TitleArrayFromResult\next
next()
Definition: TitleArrayFromResult.php:80
TitleArrayFromResult\count
count()
Definition: TitleArrayFromResult.php:68
TitleArrayFromResult\key
key()
Definition: TitleArrayFromResult.php:76
TitleArrayFromResult\__construct
__construct( $res)
Stable to call.
Definition: TitleArrayFromResult.php:47
TitleArrayFromResult\rewind
rewind()
Definition: TitleArrayFromResult.php:86
TitleArrayFromResult\$key
$key
Definition: TitleArrayFromResult.php:38
TitleArrayFromResult\$res
IResultWrapper $res
Definition: TitleArrayFromResult.php:36
TitleArray
The TitleArray class only exists to provide the newFromResult method at pre- sent.
Definition: TitleArray.php:35
TitleArrayFromResult\valid
valid()
Definition: TitleArrayFromResult.php:95