MDB2 checking valid connection
| From: | Stoyan Stefanov | Date: | Thu, 29 Dec 2005 04:41:40 +0000 |
| Subject: | MDB2 checking valid connection | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-40849@lists.php.net to get a copy of this message | ||
Hi guys,
MDB2 team - great job on the package! Kudos to Lucas Smith - last week
I logged two issues and they were fixed within hours! Pretty
impressive ;)
Now I have a small issue, and I'm not sure if I should log a bug on
this, so here goes.
In the example.php from MDB2's /doc there is the following code:
$db =& MDB2::factory($dsn);
// With PEAR::isError you can differentiate between an error or
// a valid connection.
if (PEAR::isError($db)) {
die (__LINE__.$db->getMessage());
}
I don't think that's a valid way to check the connection, $db will
never be an error object, because the connection is not tried at this
point. AFAIK, connection is attempted on-demand, during the first real
database operation, e.g. a query.
And so my question is what is the best way to check for a valid connection?
Regards,
Stoyan
--
Stoyan Stefanov
http://www.phpied.com