MediaWiki REL1_32
TitleArrayFromResult.php
Go to the documentation of this file.
1<?php
28
29class 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}
The TitleArray class only exists to provide the newFromResult method at pre- sent.
Result wrapper for grabbing data queried from an IDatabase object.