From:             shen dot shenstone at gmail dot com
Operating system: Windows
PHP version:      5.1.4
PHP Bug Type:     PDO related
Bug description:  execute two sequence query cause error when they only in two 
different class

Description:
------------
execute two sequence query cause error when they only in two different
class.

the following code run WELL.
<?php
$db_host    = 'localhost';
$db_name    = 'jeon';
$db_port    = '3506';
$db_user    = 'test';
$db_pwd     = 'test';

$db = new PDO("mysql:host=$db_host;dbname=$db_name;port=$db_port",
$db_user, $db_pwd, array(PDO::ATTR_PERSISTENT => true));
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$r = $GLOBALS['db']->prepare("SELECT COUNT(*) FROM teacher WHERE
teacherid=? AND password=?");
$r->execute(array('a', 'a'));

$r = $GLOBALS['db']->prepare("SELECT COUNT(*) FROM teacher WHERE
teacherid=? AND password=?");
$r->execute(array('b', 'b'));
?>

But if i move the query code to different class, it does not working and
raise a error.
"General error: 2014 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."

only when i insert $r->closeCursor(); in the first class, they are
working.

sorry for my bad english. ;)

Reproduce code:
---------------
<?php
$db_host    = 'localhost';$db_name    = 'jeon';$db_port    =
'3506';$db_user    = 'test';$db_pwd     = 'test';
$db = new PDO("mysql:host=$db_host;dbname=$db_name;port=$db_port",
$db_user, $db_pwd, array(PDO::ATTR_PERSISTENT => true));
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
class Session{
    public function start_new() {
        $r = $GLOBALS['db']->prepare("SELECT COUNT(*) FROM teacher WHERE
teacherid=? AND password=?");
        $r->execute(array('b', 'b'));
    }
}
class Test{
    function dotest() {
        $r = $GLOBALS['db']->prepare("SELECT COUNT(*) FROM teacher WHERE
teacherid=? AND password=?");
        $r->execute(array('a', 'a'));
        //$r->closeCursor();
        $GLOBALS['session']->start_new();
    }
}
$session = new Session();$test = new Test();$test->dotest();
?>


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

Reply via email to