From c04e80e32804b8d9c202a307a821f2ba45abaeb6 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sat, 5 Nov 2011 09:26:12 +0100 Subject: [PATCH] MDL-30147 detect missing table when processing query conditions --- lib/dml/moodle_database.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/dml/moodle_database.php b/lib/dml/moodle_database.php index 00bbd96b409..cbb88950fa9 100644 --- a/lib/dml/moodle_database.php +++ b/lib/dml/moodle_database.php @@ -506,10 +506,15 @@ abstract class moodle_database { $columns = $this->get_columns($table); foreach ($conditions as $key=>$value) { if (!isset($columns[$key])) { - $a = new stdClass(); - $a->fieldname = $key; - $a->tablename = $table; - throw new dml_exception('ddlfieldnotexist', $a); + if (empty($columns)) { + // no supported columns means most probably table does not exist + throw new dml_exception('ddltablenotexist', $table); + } else { + $a = new stdClass(); + $a->fieldname = $key; + $a->tablename = $table; + throw new dml_exception('ddlfieldnotexist', $a); + } } $column = $columns[$key]; if ($column->meta_type == 'X') {