_db_query_process_args

  1. drupal
    1. drupal7
Versionen
drupal7 _db_query_process_args($query, $args, $options)

Backward-compatibility utility.

This function should be removed after all queries have been converted to the new API. It is temporary only.

@todo Remove this once the query conversion is complete.

Verwandte Themen

▾ 3 functions call _db_query_process_args()

db_query in includes/database/database.inc
Execute an arbitrary query string against the active database.
db_query_range in includes/database/database.inc
Execute an arbitrary query string against the active database, restricted to a specified range.
db_query_temporary in includes/database/database.inc
Execute a query string against the active database and save the result set to a temp table.

Code

includes/database/database.inc, line 2503

<?php
function _db_query_process_args($query, $args, $options) {

  if (!is_array($options)) {
    $options = array();
  }
  if (empty($options['target'])) {
    $options['target'] = 'default';
  }

  // Temporary backward-compatibility hacks. Remove later.
  $old_query = $query;
  $query = str_replace(array('%n', '%d', '%f', '%b', "'%s'", '%s'), '?', $old_query);
  if ($old_query !== $query) {
    $args = array_values($args); // The old system allowed named arrays, but PDO doesn't if you use ?.
  }

  // A large number of queries pass FALSE or empty-string for
  // int/float fields because the previous version of db_query()
  // casted them to int/float, resulting in 0. MySQL PDO happily
  // accepts these values as zero but PostgreSQL PDO does not, and I
  // do not feel like tracking down and fixing every such query at
  // this time.
  if (preg_match_all('/%([dsfb])/', $old_query, $m) > 0) {
    foreach ($m[1] as $idx => $char) {
      switch ($char) {
        case 'd':
          $args[$idx] = (int) $args[$idx];
          break;
        case 'f':
          $args[$idx] = (float) $args[$idx];
          break;
      }
    }
  }

  return array($query, $args, $options);
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen