Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/dml/mysqli_native_moodle_recordset.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00018 
00028 defined('MOODLE_INTERNAL') || die();
00029 
00030 require_once($CFG->libdir.'/dml/moodle_recordset.php');
00031 
00035 class mysqli_native_moodle_recordset extends moodle_recordset {
00036 
00037     protected $result;
00038     protected $current;
00039 
00040     public function __construct($result) {
00041         $this->result  = $result;
00042         $this->current = $this->fetch_next();
00043     }
00044 
00045     public function __destruct() {
00046         $this->close();
00047     }
00048 
00049     private function fetch_next() {
00050         if ($row = $this->result->fetch_assoc()) {
00051             $row = array_change_key_case($row, CASE_LOWER);
00052         }
00053         return $row;
00054     }
00055 
00056     public function current() {
00057         return (object)$this->current;
00058     }
00059 
00060     public function key() {
00062         if (!$this->current) {
00063             return false;
00064         }
00065         $key = reset($this->current);
00066         return $key;
00067     }
00068 
00069     public function next() {
00070         $this->current = $this->fetch_next();
00071     }
00072 
00073     public function valid() {
00074         return !empty($this->current);
00075     }
00076 
00077     public function close() {
00078         if ($this->result) {
00079             $this->result->close();
00080             $this->result  = null;
00081         }
00082         $this->current = null;
00083     }
00084 }
 All Data Structures Namespaces Files Functions Variables Enumerations