Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/dml/oci_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 
00032 class oci_native_moodle_recordset extends moodle_recordset {
00033 
00034     protected $stmt;
00035     protected $current;
00036 
00037     public function __construct($stmt) {
00038         $this->stmt  = $stmt;
00039         $this->current = $this->fetch_next();
00040     }
00041 
00042     public function __destruct() {
00043         $this->close();
00044     }
00045 
00046     private function fetch_next() {
00047         if ($row = oci_fetch_array($this->stmt, OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS)) {
00048             $row = array_change_key_case($row, CASE_LOWER);
00049             unset($row['oracle_rownum']);
00050             array_walk($row, array('oci_native_moodle_database', 'onespace2empty'));
00051         }
00052         return $row;
00053     }
00054 
00055     public function current() {
00056         return (object)$this->current;
00057     }
00058 
00059     public function key() {
00061         if (!$this->current) {
00062             return false;
00063         }
00064         $key = reset($this->current);
00065         return $key;
00066     }
00067 
00068     public function next() {
00069         $this->current = $this->fetch_next();
00070     }
00071 
00072     public function valid() {
00073         return !empty($this->current);
00074     }
00075 
00076     public function close() {
00077         if ($this->stmt) {
00078             oci_free_statement($this->stmt);
00079             $this->stmt  = null;
00080         }
00081         $this->current = null;
00082     }
00083 }
 All Data Structures Namespaces Files Functions Variables Enumerations