Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
function db_result($result) {
if ($result && pg_num_rows($result) > 0) {
$array = pg_fetch_row($result);
return $array[0];
}
return FALSE;
}
database.mysql.inc:
function db_result($result) {
if ($result && mysql_num_rows($result) > 0) {
// The mysql_fetch_row function has an optional second parameter $row
// but that can't be used for compatibility with Oracle, DB2, etc.
$array = mysql_fetch_row($result);
return $array[0];
}
return FALSE;
}
database.mysqli.inc:
function db_result($result) {
if ($result && mysqli_num_rows($result) > 0) {
// The mysqli_fetch_row function has an optional second parameter $row
// but that can't be used for compatibility with Oracle, DB2, etc.
$array = mysqli_fetch_row($result);
return $array[0];
}
return FALSE;
}
All three return FALSE when a result is not found. If you can provide an example, we can test it, but right now it looks correct.
Comments
Comment #1
add1sun commentedMoving to correct queue.
Comment #2
heine commentedWith the mysqli db driver:
Results in
bool(false), gettype() confirms bool.Comment #3
heine commentedBased on a comment of Jmorahan I tried it with the mysql driver as well, still a bool on 6.x-dev
Comment #4
heine commentedThe same issue was fixed in #98988: db_result should return FALSE if no result was found., long before 6.x.
Comment #5
dave reiddatabase.pgsql.inc:
database.mysql.inc:
database.mysqli.inc:
All three return FALSE when a result is not found. If you can provide an example, we can test it, but right now it looks correct.
Comment #6
epimeth commentedSeems like it was fixed on some earlier update. Thanks all!