ID:               39858
 Comment by:       james dot cordon at btinternet 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:

AHHHHHH!!!!

My bodge-it above doesn't work correctly, it just opens but doesn't
close many connections.

This does work (tried several times on 200 consec' queries)
added closeCursor().


$i=100;
        
        while($i>0){
        echo 'LOOP NUM:'.$i.'<br />';
                try{
                        $stmt=$pdodl_1->query("call testMany()");
                        $stmt->setFetchMode(PDO::FETCH_ASSOC);
        
                        echo '<br />PDODL OBJ: ';
                        var_dump($pdodl_1);
                        echo '<br />PDO::STATEMENT OBJ: <br />';
                        var_dump($stmt);
                        echo '<br /><br />';
        
                        while ($row= $stmt->fetch()) {
                                echo '<br />';
                                var_dump($row);
                                echo '<br />';
                }
                $i--;
        
        
                }catch(PDOException $e){
                        if($e->getCode()=='HY000'){
                        $stmt->closeCursor();
                        $pdodl_1->connect();
                        $i--;
                        } else {
                        throw $e;
                        }
                }
        }


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

[2007-02-22 11:37:01] james dot cordon at btinternet dot com

php 5.2.1
win xp pro
mysql 5x
apache 2x

I also built a project assuming stored procedures would work
as they are mentioned in the php docs, anyway.

to cut a long story short, I extended PDO with methods that included
not connectimg to DB until actually needed.

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

When  calling a 2nd query (after a stored procedure) I get the
"SQLSTATE[HY000]:
General error: 2013 Lost connection to MySQL server during query" every
time.

I discovered calling "$pdoextended->connect();" after each use of a
stored procedure revived the connection (without instantiating another
PDOextended obj) with no errors.

This is ONLY a bodge-it but it is a very lightweight one.

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

[2007-02-20 14:24:37] barney dot hanlon at markettiers4dc dot com

That would technically be a workaround rather then a fix.  The issue is
still there, and switching to ODBC is not necessarily a good or
acceptable solution.  Also as we have taken onboard the Zend Framework
prior to beginning work on Zend Platform, creating non-standard
solutions doesn't sound like a forward step.  

However, until the PHP team pull their fingers out and assess PDO to
work with Windows properly, I may have to implement it.  Thank goodness
that the partnership with Microsoft will force PHP to stop treating IIS
as a perochial platform and get proper support.

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

[2007-02-19 18:45:52] denis dot podgurskiy at cofelab dot ru

Hi once again.
Step by step instruction how to work with MySQL sp/transaction under
Win XP SP 2
1. Install MySQL ODBC driver.
2. Create database with tables in InnoDB format (to support transaction
- see my.cnf).
3. Create DSN with connection to your database (see Admin
tools->ODBC).
4. Enable pdo_odbc within php.ini file.
5. Use this to create connection
                if(strstr($_SERVER['SERVER_SOFTWARE'],'Win')){
                        $this -> Db = new PDO("odbc:DSN=MY_MySQL_ODBC;", user, 
password);       
                } else {
                        $this -> Db = Zend_Db::factory( PDO_MYSQL);
6. When the sp has been executed do not forget to fetch the statement:
                        $command -> execute();
                        do {
                           $rows = $command->fetchAll();
                        } while ($command -> nextRowset());
That's all. This code will work under win/nix without any diffireneces
- checked by me.
If you still have any problems - just email me and I'll contact you by
ICQ/Skype to help (I spent four weeks to solve it).
Regards, Denis

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

[2007-02-15 13:56:39] mike at we11er dot co dot uk

Thanks for the help Denis, although I can't personally implement this
workaround...

For the time being I have hacked in lines of code to create a new
database connection before calling certain stored procedures.

Now, PLEASE could a developer or someone RESPOND and acknowledge this
bug, and let us know what is going on!?

I've been stuck with this bug for months and months with no help
whatsoever from the PHP guys.

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

[2007-02-07 09:25:31] denis dot podgurskiy at cofelab dot ru

It works under Nix as well. So, good luck.

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

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