Re: Pear_Error not triggered when mysql is down with MDB2
| From: | Justin Patrin | Date: | Thu, 07 Jul 2005 18:26:49 +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-19898@lists.php.net to get a copy of this message | ||
On 7/7/05, Dan Rossi <pear@electroteque.org> wrote:
>
> On 08/07/2005, at 12:38 AM, Lorenzo Alberton wrote:
>
> > Dan Rossi wrote:
> >> Hi there I just realised something, if the database server is down no
> >> pear error gets triggered like the rest
> >> 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 ? 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'm not sure what you're asking here, but a connect failure should
return a PEAR_Error from the ::connect factory. So you have to check
to make sure that your supposed MDB object isn't a PEAR_Error before
using it. This is what Lorenzo was telling you.
--
Justin Patrin