Fetch one result row from the previous query as an array.
Parameters
$result: A database query result resource, as returned from db_query().
Return value
An associative array representing the next row of the result, or FALSE. The keys of this object are the names of the table fields selected by the query, and the values are the field values for this result row.
Related topics
File
- includes/
database.pgsql.inc, line 189 - Database interface code for PostgreSQL database servers.
Code
<?php
function db_fetch_array($result) {
if ($result) {
return pg_fetch_assoc($result);
}
}
?> Login or register to post comments
Comments
This function can also return NULL
The PHP default function return is null. If you pass something in which causes the if statement to skip then it will return NULL and not FALSE.
Did this recently and ended up with an endless loop ....
$result = db_query(''SQL with a typo");
while (($next_record = db_fetch_array($result) !== FALSE) {
some code
}
For Drupal 7..
good comments here:
http://api.drupal.org/api/drupal/includes--database--database.inc/functi...