Home » Database » DB_DataObject » Bug #2928
error in ->query does not raise exception
Details
| Submitted | 2004-12-08 21:23 UTC |
|---|---|
| From | amiel dot martin at gmail dot com |
| Assigned | alan_k |
| Status | Closed |
| Package | DB_DataObject |
| PHP Version | 4.3.8 |
| OS | debian Woody |
| Roadmaps | (Not assigned) |
Comments
[2004-12-08 21:23 UTC] amiel dot martin at gmail dot com
Description:
------------
there is no way to determine if I have an error in my query when I use the ->query() (besides turing the debug level).
1.7.2
Reproduce code:
---------------
DB_DataObject::debugLevel(1);
$blah = new DataObjects_students;
$blah->query("SELECT * FROMs {$blah->__table} where id < 5 ORDER BY id");
print_r($blah)
if ($blah->_lastError)
echo "Error: {$blah->_lastError->message}<p>";
Expected result:
----------------
I would expect $blah->_lastError to be set with a db_dataobject_error
Actual result:
--------------
debug recognizes the error in the query string, but the print_r call reveals that $blah->_lastError is not set.
Have I missed a way to determine if my ->query() call was successfull?
dataobjects_students: QUERY: SELECT * FROMs students where id < 5 ORDER BY id
dataobjects_students: Query Error: [db_error: message="DB Error: syntax error" code=-2 mode=return level=notice prefix="" info="SELECT * FROMs students where id < 5 ORDER BY id [nativecode=1064 ** You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROMs students where id < 5 ORDER BY id' at line 1]"]
dataobjects_students Object ( [__table] => students [_DB_DataObject_version] => 1.7.2 [N] => 0 [_database_dsn] => [_database_dsn_md5] => d3594a34009c2104456bdeb36f7ed27d [_database] => hsi [_query] => Array ( [condition] => [group_by] => [order_by] => [having] => [limit] => [data_select] => * ) [_DB_resultid] => [_link_loaded] => [_join] => [_lastError] => )