You are here

function _db_query_callback in Drupal 4

Same name and namespace in other branches
  1. 5 includes/database.inc \_db_query_callback()
  2. 6 includes/database.inc \_db_query_callback()

Helper function for db_query().

Related topics

8 calls to _db_query_callback()
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

8 string references to '_db_query_callback'
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.inc, line 141
Wrapper for database interface code.

Code

function _db_query_callback($match, $init = FALSE) {
  static $args = NULL;
  if ($init) {
    $args = $match;
    return;
  }
  switch ($match[1]) {
    case '%d':

      // We must use type casting to int to convert false/null/(true?)
      return (int) array_shift($args);

    // We don't need db_escape_string as numbers are db-safe
    case '%s':
      return db_escape_string(array_shift($args));
    case '%%':
      return '%';
    case '%f':
      return (double) array_shift($args);
    case '%b':

      // binary data
      return db_encode_blob(array_shift($args));
  }
}