This is how I implented this for mysql.
This routine is sometimes useful.

/**
 * Fetch the first and only field from result row from the previous query.
 *
 * @param $result
 *   A database query result resource, as returned from db_query().
 * @return
 *   A single value from the row or null.
 */

function db_fetch_value($result) {
	if ($result) {
		$row =  mysql_fetch_row($result);
		if ( $row ) return ( $row[0] );
		else return(null);
	}
}

Comments

yched’s picture

Status: Active » Closed (won't fix)

??
db_result() function already exists in drupal API.

Plus you should really not use such functions as mysql_fetch_row in drupal code (unless maybe you know exactly what you are doing). Use drupal db_api instead