MediaWiki  REL1_22
ORMResult.php
Go to the documentation of this file.
00001 <?php
00032 class ORMResult implements ORMIterator {
00033 
00037     protected $res;
00038 
00042     protected $key;
00043 
00047     protected $current;
00048 
00052     protected $table;
00053 
00058     public function __construct( IORMTable $table, ResultWrapper $res ) {
00059         $this->table = $table;
00060         $this->res = $res;
00061         $this->key = 0;
00062         $this->setCurrent( $this->res->current() );
00063     }
00064 
00068     protected function setCurrent( $row ) {
00069         if ( $row === false ) {
00070             $this->current = false;
00071         } else {
00072             $this->current = $this->table->newRowFromDBResult( $row );
00073         }
00074     }
00075 
00079     public function count() {
00080         return $this->res->numRows();
00081     }
00082 
00086     public function isEmpty() {
00087         return $this->res->numRows() === 0;
00088     }
00089 
00093     public function current() {
00094         return $this->current;
00095     }
00096 
00100     public function key() {
00101         return $this->key;
00102     }
00103 
00104     public function next() {
00105         $row = $this->res->next();
00106         $this->setCurrent( $row );
00107         $this->key++;
00108     }
00109 
00110     public function rewind() {
00111         $this->res->rewind();
00112         $this->key = 0;
00113         $this->setCurrent( $this->res->current() );
00114     }
00115 
00119     public function valid() {
00120         return $this->current !== false;
00121     }
00122 
00123 }