From:             mail at chrismandery dot de
Operating system: Gentoo AMD64 & Ubuntu 7.04
PHP version:      5.2.4
PHP Bug Type:     PDO related
Bug description:  PDO-MySQL: Invalid return code for execute()

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.

-- 
Edit bug report at http://bugs.php.net/?id=42620&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42620&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42620&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42620&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42620&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42620&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42620&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42620&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42620&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42620&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42620&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42620&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42620&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42620&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42620&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42620&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42620&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42620&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42620&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42620&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42620&r=mysqlcfg

Reply via email to