Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 3e53989

Browse files
committed
Allowed params names with : at the beginning
PHP supports binding params with `:` and without. As we add it always we should strip it out first before checking the name with regular expression, and add it at the end.
1 parent 69118aa commit 3e53989

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/Adapter/Driver/Pdo/Pdo.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ public function getPrepareType()
304304
public function formatParameterName($name, $type = null)
305305
{
306306
if ($type === null && ! is_numeric($name) || $type == self::PARAMETERIZATION_NAMED) {
307+
$name = ltrim($name, ':');
307308
// @see https://bugs.php.net/bug.php?id=43130
308309
if (preg_match('/[^a-zA-Z0-9_]/', $name)) {
309310
throw new Exception\RuntimeException(sprintf(

test/Adapter/Driver/Pdo/PdoTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function getParamsAndType()
5353
[ '123foo', Pdo::PARAMETERIZATION_NAMED, ':123foo' ],
5454
[ 1, Pdo::PARAMETERIZATION_NAMED, ':1' ],
5555
[ '1', Pdo::PARAMETERIZATION_NAMED, ':1' ],
56+
[ ':foo', null, ':foo' ],
5657
];
5758
}
5859

0 commit comments

Comments
 (0)