Re: DB error

From: Date: Wed, 23 Nov 2005 19:55:08 +0000
Subject: Re: DB error
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-22067@lists.php.net to get a copy of this message
On 11/22/05, Michael Rasmussen <mir@miras.org> wrote: > On Tue, 22 Nov 2005 14:45:17 -0800, Justin Patrin wrote: > > > Your isError call should catch such cases. Try doing a print_r of $res > > when such a thing happens to see what it is. Perhaps: if (!is_a($res, > > 'DB_Result')) { > > print_r($res); > > } > > to see what's happening. > In those rare situations when the connection is lost between obtaining a > resource and using the resource isError will not catch the error. E.g the > isError will only catch errors related to $res =& $db->query($sql) but not > errors related to $res->fetchRow(). Remember $res is only holding a > reference to some place in the database servers memory where the actual > data are receding. > Actually the isError() call *should work. What is happening here is not necessarily a lost connection. In fact, it most likely isn't that at all. Whether or not the connection is lost $res should still be a valid object and either a valid DB_Result or a PEAR_Error. It should never be a non-object. If something other than either of those 2 objects is returned from ->query then it's a bug. *Or* perhaps the query is a manipulation query and DB is returning DB_OK, as is specified in the docs. If the query is a SELECT query the return should always be a DB_Result or a PEAR_Error. If it's a manipulation query it should be DB_OK (a non object) or a PEAR_Error. In the second case you'd get the error outlined above. -- Justin Patrin

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