ID:               39858
 Comment by:       paulsidekick at gmail dot com
 Reported By:      develar at gmail dot com
 Status:           Assigned
 Bug Type:         PDO related
 Operating System: Windows XP SP2
 PHP Version:      5.2.0
 Assigned To:      wez
 New Comment:

I am still not able to issue two stored procedures in a row using PDO
and mysql 5.0.31, php 5.2.1 and windows server 2003 when using the php
pdo_mysql.dll extension.  Is there any fix for this planned?  It has
been a very long time since it was first noted. If there is a solution
other than using a hacked DLL with no source code, can somebody please
advice.  This is the simplest way to see it happen.

$stmt = $myPdoConnection->query("CALL myStoredProc ('x',  'y')");

//this returns results
print_r($stmt->fetchAll());

//this does not - says mysql lost connection
print_r($stmt->fetchAll());

If I do this with SELECT statements instead I get no problem.  I
believe that there is an additional row set send back with stored
procedures from mysql that needs to be interated over in order to issue
the next statement.  However, I cannot access them with 

$stmt->nextRowset();

as I get "Warning: PDOStatement::nextRowset()
[function.PDOStatement-nextRowset]: SQLSTATE[HYC00]: Optional feature
not implemented in "

Please help.


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

[2007-04-09 19:13:53] jaylehvee at srgtampa dot com

I am using this modified DLL, above, and it works great, in most
regards. The core issue still exists, however. Mulitple calls to stored
procedures are still causing db connection loss. I've had to go
lazy-load kuh-ray-zee on my objects to avoid connection failures. I
shouldn't have to use the wrong patterns in order to work around a
faulty db driver.

Mike, any chance you can post your hacked source somewhere?

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

[2007-03-26 19:57:43] timo at hhesse dot de

Hi mike, thanks for the fixed php_pdo_mysql.dll! I tested it right now
and it works perfectly!
It took me quite the whole day finding out that it was a php bug what
made my stored procedures producing those exceptions (on Windows IIS).

But now I'm asking myself if your fix will find its way into the next
PHP release so that I can be sure my code will work at my customers
Windows servers too or if I should use some script language that
supports stored procedures as they are meant...

A reliable answer in this issue would be great! ;-)

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

[2007-03-09 13:24:09] mike at we11er dot co dot uk

Hi everyone. We have a fixed php_pdo_mysql.dll in our svn repos - but
the guy that compiled it all hasn't got the source together because it
involved a massive overhaul of the php and extension code to support the
latest mysql libs.

I know your first thoughts will be "There's no way I'm going to use a
.dll from a *hackthissite*!", that's fine... but the guy that compiled
it can be trusted, and I've been using it on my windows machine for a
week or two now.

http://source.hackthissite.org/wsvn/HTSv4/trunk/PDO/php_pdo_mysql.dll

I'll see if we can get some sort of source code version together. Until
then, use this at your own risk.

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

[2007-02-27 16:29:58] james dot cordon at btinternet dot com

What I have stated previously works, but only with the PHP vers. of
libmysql.dll {error lost connection}
mysql vers. {error unbuffered queries} just keeps making new
connections until it is maxed out, have found no solution to this.

I am using the very latest vers of everything.

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

[2007-02-23 12:09:20] james dot cordon at btinternet dot com

previous doesn't address stored procedure prob (from what i've read
this is a win prob only).

my revised approach:
Essentialy after you use a stored procedure call, burn another  query
to force an exception.

###
private $connect_a=array();
private $connected=0;

public function __construct($dsn=NULL, $user=NULL, $pass=NULL){
        if(is_array($dsn)){
        $this->connect_a['DSN']=$dsn[0];
        $this->connect_a['U']=$dsn[1];
        $this->connect_a['P']=$dsn[2];
        } else {
        $this->connect_a['DSN']=$dsn;
        $this->connect_a['U']=$user;
        $this->connect_a['P']=$pass;
        }
}//

public function query($q){
        if($this->connected==0){
        $this->connect();
        }
return parent::query($q);
}//

public function dropConnection($stmt){
$stmt->closeCursor();
$this->connected=0;
}##


public function callStoredProcedure($stmt){
$resultset;
try{
        #multi array
        while ($row= $stmt->fetch()) {
        $resultset[]=$row;
        echo '<br />';
        var_dump($row);
        echo '<br />';
   }
        #burn
        if(stripos($_SERVER['SERVER_SOFTWARE'], 'win') ){
        $stmt=$this->query("select 1+1");
        }
                        
                        
}catch(PDOException $e){
        if($e->getCode()=='HY000' AND strpos ($e->getMessage(), 'Lost
connection' )){
        print "<-!!!- Error!: Caught 'Lost connection error, dropConnection()
-!!!-><br />";
        $this->dropConnection($stmt);
        } else {
        throw $e;
        }
}
return $resultset;
}//

public function connect(){
#if($this->connected==1) return true;
try{
parent::__construct($this->connect_a['DSN'], $this->connect_a['U'],
$this->connect_a['P']);
} catch (Exception $e) {
throw($e);
}
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->connected=1;
}//

#EXAMPLE
#just to prove obj is same one
$pdodl_1->temp_id='AAAAAA';

$i=100;
        
        do{
        echo 'LOOP NUM:'.$i.'<br />';
        echo '<br />PDODL OBJ: ';
        var_dump($pdodl_1);
        echo '<br /><br />';
        $stmt=$pdodl_1->query("call testMany()");
        $stmt->setFetchMode(PDO::FETCH_ASSOC);
        $rset=$pdodl_1->callStoredProcedure($stmt);
                        
        $i--;
        } while($i>0);

This is all from another project, so may need some tinkering.

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

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/39858

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

Reply via email to