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.
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 ) {