]> git.mjollnir.org Git - moodle.git/commitdiff
Add LIMIT of 1 to get_record functions ... the behaviour of returning false
authormoodler <moodler>
Thu, 19 Jun 2003 02:18:51 +0000 (02:18 +0000)
committermoodler <moodler>
Thu, 19 Jun 2003 02:18:51 +0000 (02:18 +0000)
when there were more than one record returned was sometimes causing
problems if the data was unclean due to a bug somewhere.

For example, if there are two copies of a section, then Moodle keeps
creating new ones because it can't find ONE.  This fix prevents that.

lib/datalib.php

index 4599ef7ebdd7043a960a742ef4e0653e4e474879..2663acf56a24beddedcad3fa65759636a7993187 100644 (file)
@@ -301,10 +301,11 @@ function get_record($table, $field1, $value1, $field2="", $value2="", $field3=""
 function get_record_sql($sql) {
 /// Get a single record as an object
 /// The sql statement is provided as a string.
+/// A LIMIT is added to keep limit the returned records to 1
 
     global $db;
 
-    $rs = $db->Execute("$sql");
+    $rs = $db->Execute("$sql LIMIT 1");
     if (empty($rs)) return false;
 
     if ( $rs->RecordCount() == 1 ) {