Currently, for mysql, mysqli and pgsql, db_fetch_array and db_fetch_object all perform this test:
if ($result) { // perform fetch
It is however less correct than:
if (is_resource($result)) { // perform fetch
Testing for is_resource instead of merely existence can catch more errors, notably by avoiding the occasional error in coding where someone tries to fetch from a query string instead of fetching from the relevant query.
OTOH, if we are ready to let non-resources be passed to the underlying fetch function, as is currently the case, there is not need to test $result and the test can be removed, possibly to be replaced by a try/catch block, although since this depends on PHP5 we probably want to wait for D7 before switching to this model.
Comments
Comment #1
michalto commentedI've attached a patch for the mentioned changes.
Comment #2
keith.smith commentedMinor coding style issue: there are some odd indents or tabs in the patch.
Comment #3
michalto commentedWhere and what exactly?
Comment #4
dpearcefl commentedIs this still an issue in current D6?