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

Commit 5dc6b4d

Browse files
committed
Merge pull request #292 from webimpress/hotfix/291
Hotfix #291 - Allowed param names with `:` at the beginning
2 parents 69118aa + 7dcee01 commit 5dc6b4d

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ All notable changes to this project will be documented in this file, in reverse
2222

2323
### Fixed
2424

25-
- Nothing.
25+
- [#292](https://github.com/zendframework/zend-db/pull/292) fixes the issue
26+
with parameter names starting from colon.
2627

2728
## 2.9.1 - 2017-12-07
2829

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)