#42113 [Opn->Csd]: Problem with placeholders and escaped quotes in string constants
| From: | johannes@php.net | Date: | Sat, 28 Jul 2007 09:16:43 +0000 |
| Subject: | #42113 [Opn->Csd]: Problem with placeholders and escaped quotes in string constants | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-115515@lists.php.net to get a copy of this message | ||
ID: 42113
Updated by: johannes@php.net
Reported By: dominique dot archambault at gmail dot com
-Status: Open
+Status: Closed
Bug Type: PDO related
Operating System: Debian lenny
PHP Version: 5.2.3
New Comment:
Then it's closed
Previous Comments:
------------------------------------------------------------------------
[2007-07-27 18:42:09] dominique dot archambault at gmail dot com
The CVS snapshot (5.2.4) worked and my test case ran flawlessly! It
would seem the bug was addressed and corrected.
Only have to wait for the official release of 5.2.4 :) Thank you very
much!
------------------------------------------------------------------------
[2007-07-27 00:04:35] iliaa@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
------------------------------------------------------------------------
[2007-07-26 16:03:44] dominique dot archambault at gmail dot com
Description:
------------
Using PHP 5.2.3 and MySQL 5.0.38.
If there are placeholders in string constants of an SQL query, and
there are also escaped quotes in a string constant (either the same
string constant, or a different one), the following error is triggered:
Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter
number: no parameters were bound in <FILE> on line <LINE>
Reproduce code:
---------------
// WORKS
$stmt = $pdo->prepare("SELECT * FROM
test WHERE
test.text =
\"Hello world's! 2007-01-01 00:00:00\"");
if ($stmt->execute()) {
print "PASSED!\n";
} else {
// should not enter this
print "FAILED!\n";
var_dump($stmt->errorInfo());
}
// DOES NOT WORK
$stmt = $pdo->prepare("SELECT * FROM test WHERE
test.text =
'Hello world\'s! 2007-01-01 00:00:00'");
// the following execute() call will generate the error
if ($stmt->execute()) {
print "PASSED!\n";
} else {
// will always enter this
print "FAILED!\n";
var_dump($stmt->errorInfo()); // will contain: array(1) { [0]=>
string(5) "HY093" }
}
Expected result:
----------------
PASSED!
PASSED!
Actual result:
--------------
PASSED!
Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter
number: no parameters were bound in <FILE> on line <LINE>
FAILED!
array(1) {
[0]=>
string(5) "HY093"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42113&edit=1