You are here

function _db_query in Drupal 4

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

Helper function for db_query().

Related topics

8 calls to _db_query()
db_query in includes/database.inc
Runs a basic query in the active database.
db_queryd in includes/database.inc
Debugging version of db_query().
db_query_range in includes/database.mysqli.inc
Runs a limited-range query in the active database.
db_query_range in includes/database.mysql.inc
Runs a limited-range query in the active database.
db_query_range in includes/database.pgsql.inc
Runs a limited-range query in the active database.

... See full list

File

includes/database.mysqli.inc, line 84
Database interface code for MySQL database servers using the mysqli client libraries. mysqli is included in PHP 5 by default and allows developers to use the advanced features of MySQL 4.1.x, 5.0.x and beyond.

Code

function _db_query($query, $debug = 0) {
  global $active_db, $queries;
  if (variable_get('dev_query', 0)) {
    list($usec, $sec) = explode(' ', microtime());
    $timer = (double) $usec + (double) $sec;
  }
  $result = mysqli_query($active_db, $query);
  if (variable_get('dev_query', 0)) {
    $bt = debug_backtrace();
    $query = $bt[2]['function'] . "\n" . $query;
    list($usec, $sec) = explode(' ', microtime());
    $stop = (double) $usec + (double) $sec;
    $diff = $stop - $timer;
    $queries[] = array(
      $query,
      $diff,
    );
  }
  if ($debug) {
    print '<p>query: ' . $query . '<br />error:' . mysqli_error($active_db) . '</p>';
  }
  if (!mysqli_errno($active_db)) {
    return $result;
  }
  else {
    trigger_error(check_plain(mysqli_error($active_db) . "\nquery: " . $query), E_USER_WARNING);
    return FALSE;
  }
}