4 * Result of a ORMTable::select, which returns ORMRow objects.
10 * @licence GNU GPL v2 or later
11 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
13 class ORMResult
implements Iterator
{
36 * @param ORMTable $table
37 * @param ResultWrapper $res
39 public function __construct( ORMTable
$table, ResultWrapper
$res ) {
40 $this->table
= $table;
43 $this->setCurrent( $this->res
->current() );
49 protected function setCurrent( $row ) {
50 if ( $row === false ) {
51 $this->current
= false;
53 $this->current
= $this->table
->newFromDBResult( $row );
60 public function count() {
61 return $this->res
->numRows();
67 public function isEmpty() {
68 return $this->res
->numRows() === 0;
74 public function current() {
75 return $this->current
;
81 public function key() {
85 public function next() {
86 $row = $this->res
->next();
87 $this->setCurrent( $row );
91 public function rewind() {
94 $this->setCurrent( $this->res
->current() );
100 public function valid() {
101 return $this->current
!== false;