3 * ORMIterator that takes a ResultWrapper object returned from
4 * a select operation returning IORMRow objects (ie IORMTable::select).
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
26 * @licence GNU GPL v2 or later
27 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
30 class ORMResult
implements ORMIterator
{
53 * @param IORMTable $table
54 * @param ResultWrapper $res
56 public function __construct( IORMTable
$table, ResultWrapper
$res ) {
57 $this->table
= $table;
60 $this->setCurrent( $this->res
->current() );
66 protected function setCurrent( $row ) {
67 if ( $row === false ) {
68 $this->current
= false;
70 $this->current
= $this->table
->newRowFromDBResult( $row );
77 public function count() {
78 return $this->res
->numRows();
84 public function isEmpty() {
85 return $this->res
->numRows() === 0;
91 public function current() {
92 return $this->current
;
98 public function key() {
102 public function next() {
103 $row = $this->res
->next();
104 $this->setCurrent( $row );
108 public function rewind() {
109 $this->res
->rewind();
111 $this->setCurrent( $this->res
->current() );
117 public function valid() {
118 return $this->current
!== false;