From 1e15c0fdad65462315daa7d3576dbb170f666479 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 28 Jan 2007 23:15:16 +0000 Subject: [PATCH] Added Oracle DIRTY HACK to both rs_fetchXX functions. Detecting of EOF in rs_fetch_record() Big improvement of rs_fetch_next_record() by using FethRow() with speeds near native fields[]. MDL-8134 Merged from MOODLE_17_STABLE --- lib/dmllib.php | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/dmllib.php b/lib/dmllib.php index 2ac5a276ca..687d57edff 100644 --- a/lib/dmllib.php +++ b/lib/dmllib.php @@ -743,8 +743,24 @@ function recordset_to_array($rs) { */ function rs_fetch_record(&$rs) { + global $CFG; + $rec = $rs->FetchObj(); //Retrieve record as object without advance the pointer + if ($rs->EOF) { //FetchObj requires manual checking of EOF to detect if it's the last record + $rec = false; + } else { + /// DIRTY HACK to retrieve all the ' ' (1 space) fields converted back + /// to '' (empty string) for Oracle. It's the only way to work with + /// all those NOT NULL DEFAULT '' fields until we definetively delete them + if ($CFG->dbfamily == 'oracle') { + $recarr = (array)$rec; /// Cast to array + array_walk($recarr, 'onespace2empty'); + $rec = (object)$recarr;/// Cast back to object + } + /// End DIRTY HACK + } + return $rec; } @@ -775,7 +791,22 @@ function rs_next_record(&$rs) { */ function rs_fetch_next_record(&$rs) { - $rec = $rs->FetchNextObj(); //Retrieve record as object without advance the pointer + global $CFG; + + $rec = false; + $recarr = $rs->FetchRow(); //Retrieve record as object without advance the pointer. It's quicker that FetchNextObj() + + if ($recarr) { + /// DIRTY HACK to retrieve all the ' ' (1 space) fields converted back + /// to '' (empty string) for Oracle. It's the only way to work with + /// all those NOT NULL DEFAULT '' fields until we definetively delete them + if ($CFG->dbfamily == 'oracle') { + array_walk($recarr, 'onespace2empty'); + } + /// End DIRTY HACK + /// Cast array to object + $rec = (object)$recarr; + } return $rec; } -- 2.39.5