]> git.mjollnir.org Git - moodle.git/commitdiff
Fix for Bug #4978 - Every time I add one field in one DB activity...
authorvyshane <vyshane>
Mon, 27 Mar 2006 06:19:34 +0000 (06:19 +0000)
committervyshane <vyshane>
Mon, 27 Mar 2006 06:19:34 +0000 (06:19 +0000)
Added AS df in SQL query in data_fieldname_exists(). Reformatted the strings
to use single quotes when quoting in SQL. These changes might solve PostgreSQL
problems.

mod/data/lib.php

index 932c26283b2ba7ee1e784b54f7a24ec971e45916..cdb734af483eff923eaf2e222dc45cd456820082 100755 (executable)
@@ -1185,12 +1185,12 @@ function data_fieldname_exists($name, $dataid, $fieldid=0) {
     global $CFG;
 
     if ($fieldid) { 
-        return record_exists_sql('SELECT * from '.$CFG->prefix.'data_fields 
-                                  WHERE name LIKE "'.$name.'" AND dataid = '.$dataid.'
-                                    AND ((id < '.$fieldid.') OR (id > '.$fieldid.'))');
+        return record_exists_sql("SELECT * from {$CFG->prefix}data_fields AS df 
+                                  WHERE df.name LIKE '$name' AND df.dataid = $dataid
+                                    AND ((df.id < $fieldid) OR (df.id > $fieldid))");
     } else {
-        return record_exists_sql('SELECT * from '.$CFG->prefix.'data_fields 
-                                  WHERE name LIKE "'.$name.'" AND dataid = '.$dataid);
+        return record_exists_sql("SELECT * from {$CFG->prefix}data_fields AS df 
+                                  WHERE df.name LIKE '$name' AND df.dataid = $dataid");
     }
 }