php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39218 parameter substitution:parameters always empty
Submitted: 2006-10-20 18:15 UTC Modified: 2006-10-21 20:38 UTC
From: jan_metzel at gmx dot de Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.1.6 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jan_metzel at gmx dot de
New email:
PHP Version: OS:

 

 [2006-10-20 18:15 UTC] jan_metzel at gmx dot de
Description:
------------
Parameter substitution in PDO::prepare() does not work.

Statement has been executed successfully but it seems like 
values of parameters are just empty strings.

Seems to occure no matter what kind of query is used 
(SELECT, INSERT, DELETE, ...).

gentoo-linux ~x86
gcc-4.1.1
mysql-4.1.21
apache-2.0.59

php-5.1.6 (r6) (gentoo)
php5.2-200610201630  (php.net snapshot)

Strange:
On an other box with almost the same software the bug does 
not occure (gcc-3.4.3 (!), mysql-4.1.21, apache-2.0.59, 
php-5.1.6 (r6))

Reproduce code:
---------------
<?php
$conn = new PDO('mysql:host=localhost;dbname=test', 'root', 'extremlysecret');

$conn->query('CREATE TABLE IF NOT EXISTS `dummy` (
 `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
 `foo` VARCHAR( 64 ) NOT NULL 
) ENGINE = MYISAM');

$ps = $conn->prepare("INSERT INTO dummy (foo) VALUES (?)");
$ps->execute(array('first try'));

$ps = $conn->prepare("INSERT INTO dummy (foo) VALUES (:val)");
$val = 'second try';
$ps->bindParam(':val', $val);
$ps->execute();

$ps = $conn->exec("INSERT INTO dummy (foo) VALUES ('this is lame but works')");

print_r($conn->query('SELECT * FROM dummy')->fetchAll(PDO::FETCH_OBJ));
?>


Expected result:
----------------
Array
(
    [0] => stdClass Object
        (
            [id] => 1
            [foo] => first try
        )

    [1] => stdClass Object
        (
            [id] => 2
            [foo] => second try
        )

    [2] => stdClass Object
        (
            [id] => 3
            [foo] => this is lame but works
        )

)


Actual result:
--------------
Array
(
    [0] => stdClass Object
        (
            [id] => 1
            [foo] => 
        )

    [1] => stdClass Object
        (
            [id] => 2
            [foo] => 
        )

    [2] => stdClass Object
        (
            [id] => 3
            [foo] => this is lame but works
        )

)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-20 21:46 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

Works just fine here.
 [2006-10-21 12:24 UTC] jan_metzel at gmx dot de
Yes, yesterday I already tested the latest snapshot
php5.2-200610201630
didn't fix it.

May the combination of gcc4 and mysql4 cause the problem in 
pdo?

because:
Finally upgraded to mysql-5.0.26 and
reinstalled gentoo's dev-lang/php-5.1.6-r6
testcase prints out expected result.
 [2006-10-21 20:38 UTC] tony2001@php.net
Then it's apparently not PHP problem.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 08:01:29 2024 UTC