From 7618a8eb9282ea60c50f9ef779255df1d202b21b Mon Sep 17 00:00:00 2001 From: moodler Date: Wed, 23 Jul 2003 06:30:26 +0000 Subject: [PATCH] More debugging/checking on get_record_sql --- lib/datalib.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/datalib.php b/lib/datalib.php index a4dfa9a035..df060091eb 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -311,22 +311,33 @@ function get_record_sql($sql) { $limit = " LIMIT 1"; // Workaround - limit to one record } - $rs = $db->Execute("$sql$limit"); + if (!$rs = $db->Execute("$sql$limit")) { + if ($CFG->debug > 7) { // Debugging mode - print checks + $db->debug=true; + $db->Execute("$sql$limit"); + $db->debug=false; + } + return false; + } - if (empty($rs)) { - return false; // Nothing found + if (!$recordcount = $rs->RecordCount()) { + return false; // Found no records } - if ( $rs->RecordCount() == 1 ) { // Found one record + if ($recordcount == 1) { // Found one record return (object)$rs->fields; - } else { // Error: found more than one record + } else { // Error: found more than one record + notify("Error: Turn off debugging to hide this error."); + notify("$sql$limit"); if ($records = $rs->GetAssoc(true)) { + notify("Found more than one record in get_record_sql !"); print_object($records); - notice("Found more than one record in get_record_sql() !"); } else { - notice("Very strange error in get_record_sql() !"); + notify("Very strange error in get_record_sql !"); + print_object($rs); } + print_continue("$CFG->wwwroot/admin/config.php"); } } -- 2.39.5