#44081 [Opn->Fbk]: Cannot execute queries while other unbuffered queries are active

From: Date: Sat, 25 Apr 2009 14:54:25 +0000
Subject: #44081 [Opn->Fbk]: Cannot execute queries while other unbuffered queries are active
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-136270@lists.php.net to get a copy of this message
 ID:               44081
 Updated by:       jani@php.net
 Reported By:      abouzekry at gmail dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         PDO related
 Operating System: Windows XP SP2
-PHP Version:      5.2.5
+PHP Version:      5.2.8
 New Comment:

Please try using this CVS snapshot:

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

  http://windows.php.net/snapshots/




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

[2009-02-25 14:18:04] stewart dot duncan at rocketmail dot com

Really annoying this one. Reproduced on 5.2.8.

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

[2008-02-09 11:46:41] abouzekry at gmail dot com

Description:
------------
the same code runs on php5.2.0 without any problems, while it's
problematic with php5.2.5 i don't know why!, it insists on giving
me the following message...

Cannot execute queries while other unbuffered queries are active.
Consider using PDOStatement::fetchAll(). Alternatively, if your code is
only ever going to run against mysql, you may enable query buffering by
setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute

however i closed the cursor after each result fetch!!!!

Reproduce code:
---------------
if(isset($_POST['user_name'], $_POST['pass']))
{

	/* check wether the user exists or not */
	$result  = $db->query("CALL proc_check_user('{$_POST['user_name']}',
'{$_POST['pass']}')")
					or
die('0-1-Database-Query-Error-login.php:'.print_r($db->errorInfo()));
	$row     = $result->fetchAll(PDO::FETCH_ASSOC)
			or
die('0-2-Database-Fetch-Error-login.php:'.print_r($db->errorInfo()));

	/* close the DB cursor to be able to perform the other querie(s)*/
	$result->closeCursor();

        /* if the user doesn't exist exit prematurely! */
	if($row['userExists'] == 0)
	{
		exit('0-2-Authentication-Error-login.php: User Doesnt Exist!');
	}

	/* get the user_id and full_name */
	$result  = $db->query("CALL
proc_get_user_data('{$_POST['user_name']}',
'{$_POST['pass']}')")
					or
die('0-3-Database-Query-Error-login.php:'.print_r($db->errorInfo()));
	$row     = $result->fetch(PDO::FETCH_ASSOC);

}

Expected result:
----------------
the machine with php5.2.0 installed when running the same code
produces
a correct authentication for valid users (POSTed) and error for invalid
users.



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


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



Thread (11 messages)

« previous php.bugs (#136270) next »