* @exception ddl_exception if error found
*
* @param string $command The sql string you wish to be executed.
- * @return vaoid
+ * @return void
*/
protected function execute_sql($sql) {
if (!$this->mdb->change_database_structure($sql)) {
- throw new ddl_exception('ddlexecuteerror', NULL, $this->mdb->get_last_error());
+ // in case driver does not throw exceptions yet ;-)
+ throw new ddl_change_structure_exception($this->mdb->get_last_error(), $sql);
}
}
$a->tablename = $tablename;
parent::__construct('ddlfieldnotexist', $a, $debuginfo);
}
-}
\ No newline at end of file
+}
+
+/**
+ * Error during changing db structure
+ */
+class ddl_change_structure_exception extends ddl_exception {
+ public $error;
+ public $sql;
+
+ function __construct($error, $sql=null) {
+ $this->error = $error;
+ $this->sql = $sql;
+ $errorinfo = s($error).'<br /><br />'.s($sql);
+ parent::__construct('ddlexecuteerror', NULL, $errorinfo);
+ }
+}
throw new dml_read_exception($this->get_last_error(), $this->last_sql, $this->last_params);
case SQL_QUERY_INSERT:
case SQL_QUERY_UPDATE:
- case SQL_QUERY_STRUCTURE:
throw new dml_write_exception($this->get_last_error(), $this->last_sql, $this->last_params);
+ case SQL_QUERY_STRUCTURE:
+ $this->get_manager(); // includes ddl exceptions classes ;-)
+ throw new ddl_change_structure_exception($this->get_last_error(), $this->last_sql);
}
}