MDB2 - Failed connection not reporting properly
| From: | J | Date: | Fri, 05 Jan 2007 21:55:18 +0000 |
| Subject: | MDB2 - Failed connection not reporting properly | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-26260@lists.php.net to get a copy of this message | ||
I'm having trouble getting a reliable answer for whether or not a connection was successful.
( It seems to always return a success, even when I change the database, user, and passwords to values I know don't exist. )
Hopefully it's not just a stupid coding issue-- which is entirely possible given that this is my first PHP application.
I tried to call getMessage() to see what is going on, however, it would appear that calling getMessage() before there is an error results in an error...
Here is the relevant code:
var $connectedToBIPS = false;
var $bipsMDB2 = null;
....
$bipsDsn=array (
'phptype' => "mysql",
'username' => $bipsUser,
'password' => $bipsPassword,
'hostspec' => BIPS_HOST,
'database' => "bipxs"
);
$options = array(
'debug' => 2,
'result_buffering' => false
);
// Notes the error in last message, but fails quietly.
$this->bipsMDB2 =& MDB2::factory($bipsDsn, $options);
if (PEAR::isError($this->bipsMDB2)) {
$this->lastMDB2message=$this->bipsMDB2->getMessage();
$this->connectedToBIPS=false;
echo "ERROR!!!";
}
else
{
$this->connectedToBIPS=true;
}
Any tips?
Thanks for your time,
--J.