function drush_db_result

8.0.x drush_db_result($result)
6.x drush_db_result($result)
7.x drush_db_result($result)
3.x drush_db_result($result)
4.x drush_db_result($result)
5.x drush_db_result($result)
master drush_db_result($result)

A db_result() that works consistently for any version of Drupal.


A Database result object.:

Related topics

8 calls to drush_db_result()
drush_user_add_role in commands/user/
Add a role to the specified user accounts.
drush_user_cancel in commands/user/
Cancels a user account.
drush_user_create in commands/user/
Creates a new user account.
drush_user_remove_role in commands/user/
Remove a role from the specified user accounts.
drush_variable_delete in commands/core/
Command callback. Delete a variable.

... See full list


includes/, line 2147
The drush API implementation and helpers.


function drush_db_result($result) {
  switch (drush_drupal_major_version()) {
    case 5:
      // In versions of Drupal <= 5, db_result only returns the first row no matter how
      //  many times you call it. So instead of calling it here, we use db_fetch_array which
      //  does increment the pointer to the next row (as db_result does on Drupal 6)
      if ($array = db_fetch_array($result)) {
        return array_shift($array); // return first element in array.
      return FALSE;
    case 6:
      return db_result($result);
    case 7:
      return $result->fetchField();