MediaWiki  master
UserArrayFromResult.php
Go to the documentation of this file.
1 <?php
24 
25 class UserArrayFromResult extends UserArray implements Countable {
27  public $res;
28 
30  public $key;
31 
33  public $current;
34 
38  function __construct( $res ) {
39  $this->res = $res;
40  $this->key = 0;
41  $this->setCurrent( $this->res->current() );
42  }
43 
48  protected function setCurrent( $row ) {
49  if ( $row === false ) {
50  $this->current = false;
51  } else {
52  $this->current = User::newFromRow( $row );
53  }
54  }
55 
59  public function count() {
60  return $this->res->numRows();
61  }
62 
66  function current() {
67  return $this->current;
68  }
69 
70  function key() {
71  return $this->key;
72  }
73 
74  function next() {
75  $row = $this->res->next();
76  $this->setCurrent( $row );
77  $this->key++;
78  }
79 
80  function rewind() {
81  $this->res->rewind();
82  $this->key = 0;
83  $this->setCurrent( $this->res->current() );
84  }
85 
89  function valid() {
90  return $this->current !== false;
91  }
92 }
static newFromRow( $row, $data=null)
Create a new user object from a user row.
Definition: User.php:696