3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
20 * Mysqli specific recordset.
24 * @copyright 2008 Petr Skoda (http://skodak.org)
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 defined('MOODLE_INTERNAL') ||
die();
30 require_once($CFG->libdir
.'/dml/moodle_recordset.php');
33 * Mysqli specific moodle recordset class
35 class mysqli_native_moodle_recordset
extends moodle_recordset
{
40 public function __construct($result) {
41 $this->result
= $result;
42 $this->current
= $this->fetch_next();
45 public function __destruct() {
49 private function fetch_next() {
50 if ($row = $this->result
->fetch_assoc()) {
51 $row = array_change_key_case($row, CASE_LOWER
);
56 public function current() {
57 return (object)$this->current
;
60 public function key() {
61 /// return first column value as key
62 if (!$this->current
) {
65 $key = reset($this->current
);
69 public function next() {
70 $this->current
= $this->fetch_next();
73 public function valid() {
74 return !empty($this->current
);
77 public function close() {
79 $this->result
->close();
82 $this->current
= null;