MediaWiki  1.34.0
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 }
UserArrayFromResult\$key
int $key
Definition: UserArrayFromResult.php:30
UserArrayFromResult\count
count()
Definition: UserArrayFromResult.php:59
UserArrayFromResult\key
key()
Definition: UserArrayFromResult.php:70
User\newFromRow
static newFromRow( $row, $data=null)
Create a new user object from a user row.
Definition: User.php:696
UserArrayFromResult\$res
IResultWrapper $res
Definition: UserArrayFromResult.php:27
UserArrayFromResult\__construct
__construct( $res)
Definition: UserArrayFromResult.php:38
UserArrayFromResult\setCurrent
setCurrent( $row)
Definition: UserArrayFromResult.php:48
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
UserArrayFromResult\current
current()
Definition: UserArrayFromResult.php:66
UserArrayFromResult
Definition: UserArrayFromResult.php:25
UserArray
Definition: UserArray.php:25
UserArrayFromResult\rewind
rewind()
Definition: UserArrayFromResult.php:80
UserArrayFromResult\$current
bool User $current
Definition: UserArrayFromResult.php:33
UserArrayFromResult\valid
valid()
Definition: UserArrayFromResult.php:89
UserArrayFromResult\next
next()
Definition: UserArrayFromResult.php:74
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:51