From a1efe9b400f4287b9a679c8df3d9915cd9edc489 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sat, 7 Jul 2012 04:53:44 +0200 Subject: [PATCH] Throw an exception when the class prototype does not match the database schema. --- class.databaserecord.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/class.databaserecord.php b/class.databaserecord.php index a5fc7af..724cbd4 100644 --- a/class.databaserecord.php +++ b/class.databaserecord.php @@ -126,6 +126,11 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass { foreach($dataset as $variable_name => $column_name) { + if(!isset($this->uData[$column_name])) + { + throw new Exception("The column name {$column_name} was not found in the resultset - ensure the prototype corresponds to the table schema."); + } + $original_value = $this->uData[$column_name]; switch($type) @@ -383,7 +388,7 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass $sQueryKeysValues = implode(", ", $sKeyValueList); $query = "UPDATE {$this->table_name} SET {$sQueryKeysValues} WHERE `{$this->id_field}` = '{$this->sId}'"; } - + pretty_dump($query); if($result = mysql_query($query)) { if($insert_mode == CPHP_INSERTMODE_INSERT)