Warning: PDO::quote() expects parameter 1 to be string, array given in dpq()
Problem/Motivation
In branch 7.x-1.x, calling dpq() with arguments that are arrays results in:
Warning: PDO::quote() expects parameter 1 to be string, array given in dpq()
Proposed resolution
function dpq($query, $return = FALSE, $name = NULL) {
...
foreach ((array) $query->arguments() as $key => $val) {
- $quoted[$key] = $connection->quote($val);
+ if (is_array($val)) {
+ $quoted[$key] = implode(', ', array_map(function($v) use ($connection) { return $connection->quote($v); }, $val));
+ }
+ else {
+ $quoted[$key] = $connection->quote($val);
+ }
}
...
}