4.6.x database.pgsql.inc db_fetch_array($result)
4.6.x database.mysql.inc db_fetch_array($result)
4.7.x database.pgsql.inc db_fetch_array($result)
4.7.x database.mysqli.inc db_fetch_array($result)
4.7.x database.mysql.inc db_fetch_array($result)
5.x database.pgsql.inc db_fetch_array($result)
5.x database.mysqli.inc db_fetch_array($result)
5.x database.mysql.inc db_fetch_array($result)
6.x database.pgsql.inc db_fetch_array($result)
6.x database.mysqli.inc db_fetch_array($result)
6.x database.mysql.inc db_fetch_array($result)

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

19 calls to db_fetch_array()
aggregator_category_load in modules/aggregator/aggregator.module
Load an aggregator category.
aggregator_feed_load in modules/aggregator/aggregator.module
Load an aggregator feed.
block_admin_configure in modules/block/block.admin.inc
Menu callback; displays the block configuration form.
block_box_get in modules/block/block.module
Returns information from database about a user-created (custom) block.
contact_load in modules/contact/contact.module
Load the data for a single contact category.

... See full list

File

includes/database.mysql.inc, line 165
Database interface code for MySQL database servers.

Code

function db_fetch_array($result) {
  if ($result) {
    return mysql_fetch_array($result, MYSQL_ASSOC);
  }
}

Comments

anthonylindsay’s picture

$sql = "select nid from node"; //your select query here
$data = db_query($sql);
// You've now got a database query object. 
// To iterate through it use this construct:
while ($item = db_fetch_array($data)) {
  // Do things to your $item array, which holds all the returned fields for 
  // one row of your query.
}