mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php //$Id$
|
|
|
|
require_once($CFG->libdir.'/dml/moodle_recordset.php');
|
|
|
|
class mysqli_native_moodle_recordset extends moodle_recordset {
|
|
|
|
protected $result;
|
|
protected $current;
|
|
|
|
public function __construct($result) {
|
|
$this->result = $result;
|
|
$this->current = $this->fetch_next();
|
|
}
|
|
|
|
public function __destruct() {
|
|
$this->close();
|
|
}
|
|
|
|
private function fetch_next() {
|
|
if ($row = $this->result->fetch_assoc()) {
|
|
$row = array_change_key_case($row, CASE_LOWER);
|
|
}
|
|
return $row;
|
|
}
|
|
|
|
public function current() {
|
|
return is_null($this->current) ? null : (object)$this->current;
|
|
}
|
|
|
|
public function key() {
|
|
/// return first column value as key
|
|
if (is_null($this->current)) {
|
|
return false;
|
|
}
|
|
$key = reset($this->current);
|
|
return $key;
|
|
}
|
|
|
|
public function next() {
|
|
$this->current = $this->fetch_next();
|
|
}
|
|
|
|
public function rewind() {
|
|
// we can not seek, sorry - let's ignore it ;-)
|
|
}
|
|
|
|
public function valid() {
|
|
return !is_null($this->current);
|
|
}
|
|
|
|
public function close() {
|
|
if ($this->result) {
|
|
$this->result->close();
|
|
$this->result = null;
|
|
}
|
|
$this->current = null;
|
|
}
|
|
}
|