php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42620 PDO-MySQL: Invalid return code for execute()
Submitted: 2007-09-10 21:37 UTC Modified: 2008-07-03 17:12 UTC
Votes:7
Avg. Score:4.6 ± 0.5
Reproduced:6 of 6 (100.0%)
Same Version:3 (50.0%)
Same OS:3 (50.0%)
From: mail at chrismandery dot de Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.2.4 OS: Gentoo AMD64 & Ubuntu 7.04
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: mail at chrismandery dot de
New email:
PHP Version: OS:

 

 [2007-09-10 21:37 UTC] mail at chrismandery dot de
Description:
------------
I am experiencing trouble with PHP using PDO with the MySQL driver. If using the same PDO statement multiple times, all calls but the first to execute() return FALSE, yet fetchAll() still returns the correct results (which may be cached from the first successful call). errorInfo() does not show any usable information.

The problem happens with both PHP 5.2.4 on 64 Bit Gentoo as with PHP 5.2.1 on 32 Bit Ubuntu (7.04 aka Feisty Fawn). It is not reproducible on SLES10 or RHEL5 though (which both have no 5.2x PHP, I think).

It's not a problem with PHP or PDO because it does not occur when using another database driver (i.e. SQLite). It is also not a problem with MySQL because execution the command multiple times per hand works fine. Some investigations using a network sniffer have shown that all three requests are properly sent to the server and correctly answered, so it should be a problem in the part that parses the answer from the MySQL server.

Reproduce code:
---------------
$db = new PDO( "mysql:host=localhost;dbname=pem", "pem", "pem" );
$q = $db->prepare( "SELECT * FROM test;" );

for ( $i = 1; $i <= 3; ++$i )
{
        if ( $q->execute() )
                echo "success in $i\n";
        else
        {
                echo "error in $i:\n";
                print_r( $q->errorInfo() );
                echo "\n";
        }

        print_r( $q->fetchAll() );
        echo "\n\n\n";

        $q->closeCursor();
}

Expected result:
----------------
success in 1
Array
(
    [0] => Array
        (
            [abc] => just a
            [0] => just a
            [def] => test!
            [1] => test!
        )

)



error in 2:
Array
(
    [0] => 00000
)

Array
(
    [0] => Array
        (
            [abc] => just a
            [0] => just a
            [def] => test!
            [1] => test!
        )

)



error in 3:
Array
(
    [0] => 00000
)

Array
(
    [0] => Array
        (
            [abc] => just a
            [0] => just a
            [def] => test!
            [1] => test!
        )

)

Actual result:
--------------
3 times success instead of 1x success + 2x error.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-16 02:17 UTC] JimmyPaterson at gmx dot de
I got the same problem on 32 bit Fedora 7 with MySQL 5.0.37 and 5.2.2.
The statement is being executed properly, the return value however is always false for subsequent calls.
 [2008-07-03 17:11 UTC] uw@php.net
Your older bug report describes the same issue as http://bugs.php.net/bug.php?id=42620 . 

I have explained over there that this is not a PDO_MYSQL bug. Its a PDO bug.

Lets close this one and continue the discussion at the newer report.

 [2008-07-03 17:12 UTC] uw@php.net
Mixing up bug numbers, blame me!
Please follow up at http://bugs.php.net/bug.php?id=45120 !
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 17:01:29 2024 UTC