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

Hotfix #291 - Allowed param names with : at the beginning #292

Merged
merged 2 commits into from
Dec 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ All notable changes to this project will be documented in this file, in reverse

### Fixed

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

## 2.9.1 - 2017-12-07

Expand Down
1 change: 1 addition & 0 deletions src/Adapter/Driver/Pdo/Pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ public function getPrepareType()
public function formatParameterName($name, $type = null)
{
if ($type === null && ! is_numeric($name) || $type == self::PARAMETERIZATION_NAMED) {
$name = ltrim($name, ':');
// @see https://bugs.php.net/bug.php?id=43130
if (preg_match('/[^a-zA-Z0-9_]/', $name)) {
throw new Exception\RuntimeException(sprintf(
Expand Down
1 change: 1 addition & 0 deletions test/Adapter/Driver/Pdo/PdoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function getParamsAndType()
[ '123foo', Pdo::PARAMETERIZATION_NAMED, ':123foo' ],
[ 1, Pdo::PARAMETERIZATION_NAMED, ':1' ],
[ '1', Pdo::PARAMETERIZATION_NAMED, ':1' ],
[ ':foo', null, ':foo' ],
];
}

Expand Down