|
Moodle
2.2.1
http://www.collinsharper.com
|
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 00027 defined('MOODLE_INTERNAL') || die(); 00028 00029 require_once($CFG->libdir.'/dml/moodle_recordset.php'); 00030 00031 class mssql_native_moodle_recordset extends moodle_recordset { 00032 00033 protected $rsrc; 00034 protected $current; 00035 00036 public function __construct($rsrc) { 00037 $this->rsrc = $rsrc; 00038 $this->current = $this->fetch_next(); 00039 } 00040 00041 public function __destruct() { 00042 $this->close(); 00043 } 00044 00045 private function fetch_next() { 00046 if ($row = mssql_fetch_assoc($this->rsrc)) { 00047 $row = array_change_key_case($row, CASE_LOWER); 00048 } 00049 return $row; 00050 } 00051 00052 public function current() { 00053 return (object)$this->current; 00054 } 00055 00056 public function key() { 00058 if (!$this->current) { 00059 return false; 00060 } 00061 $key = reset($this->current); 00062 return $key; 00063 } 00064 00065 public function next() { 00066 $this->current = $this->fetch_next(); 00067 } 00068 00069 public function valid() { 00070 return !empty($this->current); 00071 } 00072 00073 public function close() { 00074 if ($this->rsrc) { 00075 mssql_free_result($this->rsrc); 00076 $this->rsrc = null; 00077 } 00078 $this->current = null; 00079 } 00080 }