MediaWiki  REL1_23
UserArrayFromResult.php
Go to the documentation of this file.
00001 <?php
00023 class UserArrayFromResult extends UserArray implements Countable {
00024 
00028     var $res;
00029     var $key, $current;
00030 
00034     function __construct( $res ) {
00035         $this->res = $res;
00036         $this->key = 0;
00037         $this->setCurrent( $this->res->current() );
00038     }
00039 
00044     protected function setCurrent( $row ) {
00045         if ( $row === false ) {
00046             $this->current = false;
00047         } else {
00048             $this->current = User::newFromRow( $row );
00049         }
00050     }
00051 
00055     public function count() {
00056         return $this->res->numRows();
00057     }
00058 
00062     function current() {
00063         return $this->current;
00064     }
00065 
00066     function key() {
00067         return $this->key;
00068     }
00069 
00070     function next() {
00071         $row = $this->res->next();
00072         $this->setCurrent( $row );
00073         $this->key++;
00074     }
00075 
00076     function rewind() {
00077         $this->res->rewind();
00078         $this->key = 0;
00079         $this->setCurrent( $this->res->current() );
00080     }
00081 
00085     function valid() {
00086         return $this->current !== false;
00087     }
00088 }