ID:               35793
 Comment by:       brice dot laurencin at gmail dot com
 Reported By:      deadman_great at mail dot ru
 Status:           No Feedback
 Bug Type:         PDO related
 Operating System: RH Fedora Core 2
 PHP Version:      5CVS-2005-12-25 (snap)
 Assigned To:      Wez
 New Comment:

I ran against the very bug just now. I lost half a day with a bug
referenced 3 years and a half ago. Nice.
And more, just a simple affectation ain't possible? What?!?

I hate PHP more and more every day.

/rant OFF

The bug didn't occurred on Ubuntu Jaunty (PHP 5.2.6), it smashed me on
the Red Hat 4.1.1-52 (PHP 5.1.6) production server.


Previous Comments:
------------------------------------------------------------------------

[2009-03-26 15:00:18] maxlemans at free dot fr

The problem seems to be still unsolved. I reproduced it today when
using the statement variable twice or more for different queries

Code :

// Request writting
$strSQL = " 
SELECT  id
FROM    mybase.mytable
";

// Request running 
$objStatement = $oPDO->query($strSQL);

// Results browsing
while ($arrRow = $objStatement->fetch(PDO::FETCH_NUM))
{
        array_push($arrData, $arrRow[0]);
}

// Cursor closing
$objStatement->closeCursor();


// Request writting
$strSQL = " 
SELECT  id
FROM    mybase.myOTHERtable
";

// Request running 
$objStatement = $oPDO->query($strSQL);

// Results browsing
while ($arrRow = $objStatement->fetch(PDO::FETCH_NUM))
{
        array_push($arrData, $arrRow[0]);
}

// Cursor closing
$objStatement->closeCursor();


To solve this problem I use the following after
$objStatement->closeCursor() :

unset($objStatement);

As $objStatement is affected an new PDOStatement instance, I think it
would be nice if PHP could remove the previous PDOStatement instance as
it is no longer usable.

------------------------------------------------------------------------

[2008-10-30 05:35:13] post-christian at freenet dot de

I think we need to rethink about how mysql works. If you don't use
mysql_stmt_store_result(), which make sense when loading long data,
mysql seems to allow only one active statement per connection. puhh.
hard to believe but could be true. I'm having the same problem with a
mysql driver for perl.

------------------------------------------------------------------------

[2008-10-21 06:20:08] vishalraj82 at gmail dot com

I guess this is a problem with pdo.
When you connect to localhost using pdo, fire a query and store the
result in variable, the variable needs to be reset before it can be
reused, given that mysql resids on a remote server and not on
localhost.

$conn = new PDO("localhost"....
$sql1 = "SELECT * from TEST";
$res = $conn->query($sql1);
...
...


$sql2 = "SELECT * from MYTAB";
$res = $conn->query($sql2); // In this line you will get mysql general
error if $res has not been reset before being used again

------------------------------------------------------------------------

[2008-08-19 16:06:01] baptiste dot place at utopiaweb dot fr

Got the same error with second statement of a function.
Worked fine on winXP xampp, PHP 5.2.6, MySql 5.0.51b.

Deployed on a debian server with PHP 5.2.0-8 and MySQL 5.0.32, the code
threw this error.

Made it work with michal vrchota's solution, thanks a lot.

------------------------------------------------------------------------

[2008-03-19 16:40:26] ob dot php at daevel dot fr

This bug/problem is not solved with PHP 5.2.0 under Debian stable
(etch).

Full code :
<?php
$db = new pdo( 'mysql:host=localhost;dbname=admin', 'administration',
'XXX' );
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );

if( ( $res = $db->query( 'select id from user_group' ) ) !== false )
{
        print_r( $res->fetchAll() );
}

if( ( $res = $db->query( 'select description from user_group' ) ) !==
false )
{
        print_r( $res->fetchAll() );
}
?>

And result for the second query :
Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: 2050
 in /home/dev-olivier/toutgagner.admin/test.php on line 14
Array
(
)

Won't it be fixed ?

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/35793

-- 
Edit this bug report at http://bugs.php.net/?id=35793&edit=1

Reply via email to