#43130 [Asn->Csd]: bind parameter cannot contain dashes
| From: | iliaa@php.net | Date: | Mon, 29 Oct 2007 22:37:51 +0000 |
| Subject: | #43130 [Asn->Csd]: bind parameter cannot contain dashes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-119045@lists.php.net to get a copy of this message | ||
ID: 43130
Updated by: iliaa@php.net
Reported By: joel at purerave dot com
-Status: Assigned
+Status: Closed
Bug Type: PDO related
Operating System: Windows XP Home
PHP Version: 5.2.4
Assigned To: iliaa
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2007-10-29 18:07:00] joel at purerave dot com
Description:
------------
Parameters to bind in a prepared statement cannot contain dashes (-) in
the name. It probably assumes that "-value" should be another variable.
If this cannot be fixed, then at least update the documentation to make
it clear what names can and cannot be used. Using {} around the variable
name would be nice too!
Reproduce code:
---------------
$db = new PDO("mysql:host=localhost;dbname=testing", 'xxxx', 'xxxx');
$stmt = $db->prepare("SELECT id FROM testing WHERE id=:id-value");
$stmt->bindParam(':id-value', $id);
$id = 1;
$stmt->execute();
var_dump($stmt->fetch());
Expected result:
----------------
array(2) { ["id"]=> string(1) "1" [0]=> string(1) "1" }
Actual result:
--------------
Warning: PDOStatement::execute() [function.PDOStatement-execute]:
SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in
C:\htdocs\test.php on line 8
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43130&edit=1