You are here

function db_result in Drupal 6

Same name in this branch
  1. 6 includes/database.mysqli.inc \db_result()
  2. 6 includes/database.mysql.inc \db_result()
  3. 6 includes/database.pgsql.inc \db_result()
Same name and namespace in other branches
  1. 4 includes/database.mysqli.inc \db_result()
  2. 4 includes/database.mysql.inc \db_result()
  3. 4 includes/database.pgsql.inc \db_result()
  4. 5 includes/database.mysqli.inc \db_result()
  5. 5 includes/database.mysql.inc \db_result()
  6. 5 includes/database.pgsql.inc \db_result()

Return an individual result field from the previous query.

Only use this function if exactly one field is being selected; otherwise, use db_fetch_object() or db_fetch_array().

Parameters

$result: A database query result resource, as returned from db_query().

Return value

The resulting field or FALSE.

Related topics

116 calls to db_result()
actions_function_lookup in includes/actions.inc
Given an md5 hash of a function name, return the function name.
aggregator_block in modules/aggregator/aggregator.module
Implementation of hook_block().
block_add_block_form_validate in modules/block/block.admin.inc
block_admin_configure_validate in modules/block/block.admin.inc
block_flush_caches in modules/block/block.module
Implementation of hook_flush_caches().

... See full list

File

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

Code

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;
}