FAQ
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

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

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedAug 24, '11 at 8:02p
activeAug 24, '11 at 8:02p
posts1
users1
websitepear.php.net

1 user in discussion

Guppy: 1 post

People

Translate

site design / logo © 2022 Grokbase