[PEAR-BUG] Bug #18756 [Com]: MDB2::singleton does not return an error if the connection is lost

[email protected] ("guppy")
Newsgroups php.pear.bugs
Message-ID <[email protected]>
Edit report at http://pear.php.net/bugs/bug.php?id=18756&edit=1

 ID:               18756
 Comment by:       guppy
 Reported By:      jeff at zaf dot ca
 Summary:          MDB2::singleton does not return an error if the
                   connection is lost
 Status:           Open
 Type:             Bug
 Package:          MDB2
 Operating System: Linux (2.6.18-238.12.1.el5)
 Package Version:  2.4.1
 PHP Version:      5.2.10
 New Comment:

I'm pretty sure singleton is doing what the documentation is suggesting
it does. I think what's missing is a ping function to actually test the
connection.


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

[2011-08-24 21:33:16] iamnos

Description:
------------
If a script loses connection after the initial MDB2::Connect call, a 
call to MDB2::singleton does not produce an error.

Test script:
---------------
<?php
require_once('config.php');
require_once('MDB2.php');

$dsn = array(
        'phptype'  => 'mysql', 'username' => BASH_USER, 'password' =>
BASH_PASS, 'hostspec' => BASH_HOST, 'database' => BASH_NAME,
        );
$mdb2 =& MDB2::factory($dsn);
if (PEAR::isError($mdb2)) {
        echo "Connection failed\n";
        exit();
}
echo "Connected\n";
sleep(20);  // Stop mysqld
$mdb2 =&  MDB2::singleton($dsn);
if (MDB2::isError($mdb2)) {
        echo "Failed db connection\n";
   exit();
}
echo "Still Connected\n";


Expected result:
----------------
php -q test.php
Connected
Failed db connection

Actual result:
--------------
php -q test.php
Connected
Still Connected

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


-- 
Edit this bug report at http://pear.php.net/bugs/bug.php?id=18756&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.