From dc7e8cb582ab3010a2c37444a10ddd4a3aa02667 Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 19 Jun 2003 02:18:51 +0000 Subject: [PATCH] Add LIMIT of 1 to get_record functions ... the behaviour of returning false 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/datalib.php b/lib/datalib.php index 4599ef7ebd..2663acf56a 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -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 ) { -- 2.39.5