Merge branch 'w04_MDL-37718_m25_rs' of git://github.com/skodak/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2013-01-29 01:33:08 +01:00
commit 09d6bcc232
5 changed files with 47 additions and 12 deletions

View file

@ -41,9 +41,16 @@ class mssql_native_moodle_recordset extends moodle_recordset {
} }
private function fetch_next() { private function fetch_next() {
if ($row = mssql_fetch_assoc($this->rsrc)) { if (!$this->rsrc) {
$row = array_change_key_case($row, CASE_LOWER); return false;
} }
if (!$row = mssql_fetch_assoc($this->rsrc)) {
mssql_free_result($this->rsrc);
$this->rsrc = null;
return false;
}
$row = array_change_key_case($row, CASE_LOWER);
return $row; return $row;
} }

View file

@ -49,9 +49,16 @@ class mysqli_native_moodle_recordset extends moodle_recordset {
} }
private function fetch_next() { private function fetch_next() {
if ($row = $this->result->fetch_assoc()) { if (!$this->result) {
$row = array_change_key_case($row, CASE_LOWER); return false;
} }
if (!$row = $this->result->fetch_assoc()) {
$this->result->close();
$this->result = null;
return false;
}
$row = array_change_key_case($row, CASE_LOWER);
return $row; return $row;
} }

View file

@ -41,11 +41,18 @@ class oci_native_moodle_recordset extends moodle_recordset {
} }
private function fetch_next() { private function fetch_next() {
if ($row = oci_fetch_array($this->stmt, OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS)) { if (!$this->stmt) {
$row = array_change_key_case($row, CASE_LOWER); return false;
unset($row['oracle_rownum']);
array_walk($row, array('oci_native_moodle_database', 'onespace2empty'));
} }
if (!$row = oci_fetch_array($this->stmt, OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS)) {
oci_free_statement($this->stmt);
$this->stmt = null;
return false;
}
$row = array_change_key_case($row, CASE_LOWER);
unset($row['oracle_rownum']);
array_walk($row, array('oci_native_moodle_database', 'onespace2empty'));
return $row; return $row;
} }

View file

@ -62,7 +62,14 @@ class pgsql_native_moodle_recordset extends moodle_recordset {
} }
private function fetch_next() { private function fetch_next() {
$row = pg_fetch_assoc($this->result); if (!$this->result) {
return false;
}
if (!$row = pg_fetch_assoc($this->result)) {
pg_free_result($this->result);
$this->result = null;
return false;
}
if ($this->blobs) { if ($this->blobs) {
foreach ($this->blobs as $blob) { foreach ($this->blobs as $blob) {

View file

@ -41,10 +41,17 @@ class sqlsrv_native_moodle_recordset extends moodle_recordset {
} }
private function fetch_next() { private function fetch_next() {
if ($row = sqlsrv_fetch_array($this->rsrc, SQLSRV_FETCH_ASSOC)) { if (!$this->rsrc) {
unset($row['sqlsrvrownumber']); return false;
$row = array_change_key_case($row, CASE_LOWER);
} }
if (!$row = sqlsrv_fetch_array($this->rsrc, SQLSRV_FETCH_ASSOC)) {
sqlsrv_free_stmt($this->rsrc);
$this->rsrc = null;
return false;
}
unset($row['sqlsrvrownumber']);
$row = array_change_key_case($row, CASE_LOWER);
return $row; return $row;
} }