Re: Pear_Error not triggered when mysql is down with MDB2

From: Date: Thu, 07 Jul 2005 19:31:08 +0000
Subject: Re: Pear_Error not triggered when mysql is down with MDB2
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-19899@lists.php.net to get a copy of this message
Dan Rossi wrote:
I am calling the fetchmode method after creating the connection however when the server is off i get this fatal error Fatal error: Call to undefined method MDB2_Error::setFetchMode() in $this->_db = MDB2::connect($this->settings['DB_DataObject']['database'],$this-
settings['DB_DataObject']['MDB2']);
if (PEAR::isError($this->db)) {
    //uh-oh... handle error
}
$this->_db->setFetchMode(MDB2_FETCHMODE_ASSOC);
So no error is handled in connect?
of course it is... if it can't connect, it returns a MDB2_Error (which is a subclass of PEAR_Error) as it should, and which you have to check for. The dbms error is mapped into a PEAR_Error for consistency. Your error message says: Fatal error: Call to undefined method MDB2_Error::setFetchMode() in $this->_db = MDB2::connect(); that means that $this->_db is a MDB2_Error object (returned by MDB2::connect()), and that there is no such method as setFetchMode() in the MDB2_Error class. You missed the error check between the connect() and setFetchMode() calls.
No other section of MDB2 or other pear classes do I have to worry about this I have the pear errors set to a callback class.
I don't understand what you mean with the above sentence, but in theory you should check for errors after almost each method call. Regards, -- Lorenzo Alberton http://pear.php.net/user/quipo

« previous php.pear.general (#19899) next »