2
Richard and I were recently talking about it , so here it is his comment, with some modifications related to your code:
Quote:
While developing, it is nice to have feedback about what is going on. Sitting there with the logger on running your code has a particular set of requirements.
On the other hand, in a production situation, requirements are different. A false return from query() is a bad thing. That represents something seriously wrong with the SQL -- syntax errors, non-existing tables, constraint violations, etc.
The question becomes, what do YOU, as the developer, think is the appropriate response to the error?
In this particular case, the SQL error would already have been logged by the database class - it could seen in the "Queries" panel of the logger. If that is all you want to accomplish, you don't need to do anything more.
$check = $xoopsDB->query("SELECT * FROM " . $xoopsDB->prefix("employee") . " WHERE id='$employee_id' ");
Quote:
What it doesn't do is put out a message that could be seen by the user, or more significantly, seen when monitoring the site log. If something a user is running is broken, a real message in the log might be a good idea -- you won't have the luxury of seeing that logger. To generate that you need to do at least a trigger_error().
$check = $xoopsDB->query("SELECT * FROM " . $xoopsDB->prefix("employee") . " WHERE id='$employee_id' ");
if (!$check) {
trigger_error($xoopsDB->error());
}