3 * ORMIterator that takes a ResultWrapper object returned from
4 * a select operation returning IORMRow objects (ie IORMTable::select).
6 * Documentation inline and at https://www.mediawiki.org/wiki/Manual:ORMTable
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
28 * @license GNU GPL v2 or later
29 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
32 class ORMResult
implements ORMIterator
{
55 * @param IORMTable $table
56 * @param ResultWrapper $res
58 public function __construct( IORMTable
$table, ResultWrapper
$res ) {
59 $this->table
= $table;
62 $this->setCurrent( $this->res
->current() );
68 protected function setCurrent( $row ) {
69 if ( $row === false ) {
70 $this->current
= false;
72 $this->current
= $this->table
->newRowFromDBResult( $row );
79 public function count() {
80 return $this->res
->numRows();
86 public function isEmpty() {
87 return $this->res
->numRows() === 0;
93 public function current() {
94 return $this->current
;
100 public function key() {
104 public function next() {
105 $row = $this->res
->next();
106 $this->setCurrent( $row );
110 public function rewind() {
111 $this->res
->rewind();
113 $this->setCurrent( $this->res
->current() );
119 public function valid() {
120 return $this->current
!== false;