]> git.mjollnir.org Git - moodle.git/commitdiff
dmlib: Add Oracle dirty hack cleanup to recordset_to_menu() get_field_sql() and get_f...
authormartinlanghoff <martinlanghoff>
Tue, 26 Sep 2006 05:10:18 +0000 (05:10 +0000)
committermartinlanghoff <martinlanghoff>
Tue, 26 Sep 2006 05:10:18 +0000 (05:10 +0000)
This covers most (all?) the gaps in data retrieval except get_recordset_sql().

To tackle get_recordset_sql,  where the actual data retrieval is done within
AdoDB, we would have to to wrap around AdoDB with a subclass, but that would
be dirty, dirty, dirtier.

lib/dmllib.php

index b4acf182e368f942716bbf0fa6b4a0f6c8c66512..3c30c4501314a5d259251d57482600df76c78bb8 100644 (file)
@@ -766,6 +766,12 @@ function recordset_to_menu($rs) {
             $menu[$rs->fields[$key0]] = $rs->fields[$key1];
             $rs->MoveNext();
         }
+        /// Really DIRTY HACK for Oracle, but it's the only way to make it work
+        /// until we got all those NOT NULL DEFAULT '' out from Moodle
+        if ($CFG->dbtype == 'oci8po') {
+            array_walk($menu, 'onespace2empty');
+        }
+        /// End of DIRTY HACK
         return $menu;
     } else {
         return false;
@@ -872,6 +878,13 @@ function get_field_sql($sql) {
     $rs = get_recordset_sql($sql);
 
     if ($rs && $rs->RecordCount() == 1) {
+        /// 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->dbtype == 'oci8po') {
+            return onespace2empty(reset($rs->fields));
+        }
+        /// End of DIRTY HACK
         return reset($rs->fields);
     } else {
         return false;
@@ -912,6 +925,13 @@ function get_fieldset_sql($sql) {
             array_push($results, $rs->fields[$key0]);
             $rs->MoveNext();
         }
+        /// 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->dbtype == 'oci8po') {
+            array_walk($results, 'onespace2empty');
+        }
+        /// End of DIRTY HACK
         return $results;
     } else {
         return false;