Commit 212700 by webchick
#464878 by chx: Fix SQLite abstraction layer to accept arrays of placeholder values without leading :, for compatibility with PDO.
--- includes/database/sqlite/database.inc 2009/04/20 20:02:30 1.15
+++ includes/database/sqlite/database.inc 2009/05/17 03:31:36 1.16
@@ -202,11 +202,20 @@
// Else, this is using named placeholders.
foreach ($args as $placeholder => $value) {
if (is_numeric($value)) {
+ // We will remove this placeholder from the query and PDO throws an
+ // exception if the number of placeholders in the query and the
+ // arguments does not match.
+ unset($args[$placeholder]);
+ // PDO allows placeholders to not be prefixed by a colon. See
+ // <a href="http://marc.info/?l=php-internals&m=111234321827149&w=2" title="http://marc.info/?l=php-internals&m=111234321827149&w=2" rel="nofollow">http://marc.info/?l=php-internals&m=111234321827149&w=2</a> for
+ // more.
+ if ($placeholder[0] != ':') {
+ $placeholder = ":$placeholder";
+ }
// When replacing the placeholders, make sure we search for the
// exact placeholder. For example, if searching for
// ':db_placeholder_1', do not replace ':db_placeholder_11'.
$query = preg_replace('/' . preg_quote($placeholder) . '\b/', $value, $query);
- unset($args[$placeholder]);
}
}
}
+++ includes/database/sqlite/database.inc 2009/05/17 03:31:36 1.16
@@ -202,11 +202,20 @@
// Else, this is using named placeholders.
foreach ($args as $placeholder => $value) {
if (is_numeric($value)) {
+ // We will remove this placeholder from the query and PDO throws an
+ // exception if the number of placeholders in the query and the
+ // arguments does not match.
+ unset($args[$placeholder]);
+ // PDO allows placeholders to not be prefixed by a colon. See
+ // <a href="http://marc.info/?l=php-internals&m=111234321827149&w=2" title="http://marc.info/?l=php-internals&m=111234321827149&w=2" rel="nofollow">http://marc.info/?l=php-internals&m=111234321827149&w=2</a> for
+ // more.
+ if ($placeholder[0] != ':') {
+ $placeholder = ":$placeholder";
+ }
// When replacing the placeholders, make sure we search for the
// exact placeholder. For example, if searching for
// ':db_placeholder_1', do not replace ':db_placeholder_11'.
$query = preg_replace('/' . preg_quote($placeholder) . '\b/', $value, $query);
- unset($args[$placeholder]);
}
}
}