ID: 35565
Updated by: [EMAIL PROTECTED]
Reported By: capiCrimm at gmail dot com
-Status: Open
+Status: Feedback
Bug Type: PDO related
Operating System: GNU Debian Sarge
PHP Version: 5CVS-2005-12-06 (snap)
New Comment:
What version of MySQL are you using?
Previous Comments:
------------------------------------------------------------------------
[2005-12-06 06:17:30] capiCrimm at gmail dot com
Description:
------------
Using named and positional :placeholders in a PDO prepare
statement result in an empty table in MySQL. Entering in
the values into the prepare statement by hand does work,
however, and when copying over the examples from the man
to check myself I could get a nonsensical
result(196864:327683) when using 5 for the values. I added
a print in the code, but the values are also blank using
mysql CLI and the result is the same using php CLI
Reproduce code:
---------------
<?php
$conn = new PDO('mysql:dbname=testing;host=localhost;','root','');
## CREATE TABLE tbTest(one char(4), two char(4));
$stmt = $conn->prepare("INSERT INTO tbTest(one,two) VALUES (:name ,
:value)");
$stmt->bindParam(':name', $name, PDO::PARAM_STR, 4);
$stmt->bindParam(':value', $value, PDO::PARAM_STR, 4);
$name = 'val1';
$value = 'val2';
$stmt->execute();
foreach( $conn->query("SELECT * FROM tbTest", PDO::FETCH_ASSOC) as
$table ){
print " {$table['one']}:{$table['two']} ";
}
?>
Expected result:
----------------
val1:val2
Actual result:
--------------
:
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35565&edit=1