X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/includes/user/UserArrayFromResult.php diff --git a/includes/user/UserArrayFromResult.php b/includes/user/UserArrayFromResult.php new file mode 100644 index 00000000..527df7fa --- /dev/null +++ b/includes/user/UserArrayFromResult.php @@ -0,0 +1,92 @@ +res = $res; + $this->key = 0; + $this->setCurrent( $this->res->current() ); + } + + /** + * @param bool|stdClass $row + * @return void + */ + protected function setCurrent( $row ) { + if ( $row === false ) { + $this->current = false; + } else { + $this->current = User::newFromRow( $row ); + } + } + + /** + * @return int + */ + public function count() { + return $this->res->numRows(); + } + + /** + * @return User + */ + function current() { + return $this->current; + } + + function key() { + return $this->key; + } + + function next() { + $row = $this->res->next(); + $this->setCurrent( $row ); + $this->key++; + } + + function rewind() { + $this->res->rewind(); + $this->key = 0; + $this->setCurrent( $this->res->current() ); + } + + /** + * @return bool + */ + function valid() { + return $this->current !== false; + } +}