MediaWiki  REL1_24
UserArrayFromResult.php
Go to the documentation of this file.
00001 <?php
00023 class UserArrayFromResult extends UserArray implements Countable {
00025     public $res;
00026 
00028     public $key;
00029 
00031     public $current;
00032 
00036     function __construct( $res ) {
00037         $this->res = $res;
00038         $this->key = 0;
00039         $this->setCurrent( $this->res->current() );
00040     }
00041 
00046     protected function setCurrent( $row ) {
00047         if ( $row === false ) {
00048             $this->current = false;
00049         } else {
00050             $this->current = User::newFromRow( $row );
00051         }
00052     }
00053 
00057     public function count() {
00058         return $this->res->numRows();
00059     }
00060 
00064     function current() {
00065         return $this->current;
00066     }
00067 
00068     function key() {
00069         return $this->key;
00070     }
00071 
00072     function next() {
00073         $row = $this->res->next();
00074         $this->setCurrent( $row );
00075         $this->key++;
00076     }
00077 
00078     function rewind() {
00079         $this->res->rewind();
00080         $this->key = 0;
00081         $this->setCurrent( $this->res->current() );
00082     }
00083 
00087     function valid() {
00088         return $this->current !== false;
00089     }
00090 }