MediaWiki
REL1_24
|
00001 <?php 00032 class ORMResult implements ORMIterator { 00036 protected $res; 00037 00041 protected $key; 00042 00046 protected $current; 00047 00051 protected $table; 00052 00057 public function __construct( IORMTable $table, ResultWrapper $res ) { 00058 $this->table = $table; 00059 $this->res = $res; 00060 $this->key = 0; 00061 $this->setCurrent( $this->res->current() ); 00062 } 00063 00067 protected function setCurrent( $row ) { 00068 if ( $row === false ) { 00069 $this->current = false; 00070 } else { 00071 $this->current = $this->table->newRowFromDBResult( $row ); 00072 } 00073 } 00074 00078 public function count() { 00079 return $this->res->numRows(); 00080 } 00081 00085 public function isEmpty() { 00086 return $this->res->numRows() === 0; 00087 } 00088 00092 public function current() { 00093 return $this->current; 00094 } 00095 00099 public function key() { 00100 return $this->key; 00101 } 00102 00103 public function next() { 00104 $row = $this->res->next(); 00105 $this->setCurrent( $row ); 00106 $this->key++; 00107 } 00108 00109 public function rewind() { 00110 $this->res->rewind(); 00111 $this->key = 0; 00112 $this->setCurrent( $this->res->current() ); 00113 } 00114 00118 public function valid() { 00119 return $this->current !== false; 00120 } 00121 }