#35793 [Com]: General error: 2050

[email protected] ("baptiste dot place at utopiaweb dot fr")
Newsgroups php.bugs
Message-ID <[email protected]>
 ID:               35793
 Comment by:       baptiste dot place at utopiaweb dot fr
 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:

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.


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

[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 ?

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

[2006-12-28 01:22:18] dennis at inmarket dot lviv dot ua

Remember to have these "fixes" in your code on every connection you
might have to the same database.

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

[2006-11-03 08:53:42] arnaud dot lb at gmail dot com

I have the same problem with php-5.2, mysql-5.0.26 on 
Debian system.

Fixed the problem using the 
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY option.

It seems that closeCursor() does not works properly.

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

[2006-11-01 15:11:55] richard at phase dot org

$this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);

(a suggested fix above) fails on 5.2.RC6 as PDO::ATTR_EMULATE_PREPARES
appears no longer to be defined.

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

[2006-10-17 01:15:58] michal dot vrchota at seznam dot cz

I think I have solved this problem:

You have to free your PDOStatement instance

Of course You have to call closeCursor() method to be sure, but if you
have more queries and still using same identifier ($stmt) you have free
it by passing NULL value

Sample:
$stmt->closeCursor();
$stmt = NULL;

// now it works ;)

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

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.