diff options
author | Noah Heck <myesain84@gmail.com> | 2014-12-11 21:27:59 -0700 |
---|---|---|
committer | Noah Heck <myesain84@gmail.com> | 2014-12-11 21:27:59 -0700 |
commit | f871bb6d1ded0dd755e21f24714841f465d6836c (patch) | |
tree | b09f6ef384a6c5323a2905099acbb0ced68ed865 | |
parent | c81db6c19ef798bc64f32ba5149e3cb3886a7f62 (diff) | |
download | E_PDOStatement-origin/issue3-non-leading-colons.zip E_PDOStatement-origin/issue3-non-leading-colons.tar.gz E_PDOStatement-origin/issue3-non-leading-colons.tar.bz2 |
Replacement of markers with parameters /^[^:]/origin/issue3-non-leading-colons
-rw-r--r-- | E_PDOStatement.php | 32 | ||||
-rw-r--r-- | README.md | 3 |
2 files changed, 31 insertions, 4 deletions
diff --git a/E_PDOStatement.php b/E_PDOStatement.php index 97feb8b..79b1289 100644 --- a/E_PDOStatement.php +++ b/E_PDOStatement.php @@ -99,7 +99,20 @@ class E_PDOStatement extends \PDOStatement foreach ($this->boundParams as $key => $array) { - $key = (is_numeric($key)) ? "\?" : $key; + /** + * UPDATE - Issue #3 + * It is acceptable for bound parameters to be provided without the leading :, so if we are not matching + * a ?, we want to check for the presence of the leading : and add it if it is not there. + */ + if (is_numeric($key)) + { + $key = "\?"; + } + else + { + $key = (preg_match("/^\:/", $key)) ? $key : ":" . $key; + } + // $key = (is_numeric($key)) ? "\?" : $key; $value = $array; $testParam = "/" . $key . "(?!\w)/"; @@ -122,7 +135,20 @@ class E_PDOStatement extends \PDOStatement ksort($inputParams); foreach ($inputParams as $key => $replValue) { - $key = (is_numeric($key)) ? "\?" : $key; + /** + * UPDATE - Issue #3 + * It is acceptable for bound parameters to be provided without the leading :, so if we are not matching + * a ?, we want to check for the presence of the leading : and add it if it is not there. + */ + if (is_numeric($key)) + { + $key = "\?"; + } + else + { + $key = (preg_match("/^\:/", $key)) ? $key : ":" . $key; + } + // $key = (is_numeric($key)) ? "\?" : $key; $testParam = "/" . $key . "(?!\w)/"; $replValue = $this->_prepareValue($replValue); @@ -175,5 +201,3 @@ class E_PDOStatement extends \PDOStatement return $value; } } - -?> @@ -3,6 +3,9 @@ Drop in replacement for default PHP PDOStatement class allowing devs to view an interpolated version of a parameterized query ###Update +Now allows for input parameters without leading : as per issue #3. + +###Update Please update and replace with new version (as of 2014-10-22) to address potential matching issues. This is a drop-in update, so no other changes should be necessary. |