| Versionen | |
|---|---|
| drupal7 | public DatabaseConnection_pgsql::query($query, array $args = array(), $options = array()) |
includes/
<?php
public function query($query, array $args = array(), $options = array()) {
$options += $this->defaultOptions();
// The PDO PostgreSQL driver has a bug which
// doesn't type cast booleans correctly when
// parameters are bound using associative
// arrays.
// See http://bugs.php.net/bug.php?id=48383
foreach ($args as &$value) {
if (is_bool($value)) {
$value = (int) $value;
}
}
try {
if ($query instanceof DatabaseStatementInterface) {
$stmt = $query;
$stmt->execute(NULL, $options);
}
else {
$modified = $this->expandArguments($query, $args);
$stmt = $this->prepareQuery($query, !$modified);
$stmt->execute($args, $options);
}
switch ($options['return']) {
case Database::RETURN_STATEMENT:
return $stmt;
case Database::RETURN_AFFECTED:
return $stmt->rowCount();
case Database::RETURN_INSERT_ID:
return $this->lastInsertId($options['sequence_name']);
case Database::RETURN_NULL:
return;
default:
throw new PDOException('Invalid return directive: ' . $options['return']);
}
}
catch (PDOException $e) {
_db_check_install_needed();
if ($options['throw_exception']) {
if ($query instanceof DatabaseStatementInterface) {
$query_string = $stmt->getQueryString();
}
else {
$query_string = $query;
}
throw new PDOException($query_string . " - \n" . print_r($args, 1) . $e->getMessage());
}
return NULL;
}
}
?>
Kommentare
Kommentar hinzufügen