RE: [PEAR] MDB: executeQuery() - Error Handling Bug?
| From: | Lukas Smith | Date: | Wed, 19 Feb 2003 17:50:02 +0000 |
| Subject: | RE: [PEAR] MDB: executeQuery() - Error Handling Bug? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-3843@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Thomas Schulz [mailto:ths@4bconsult.de]
> Sent: Wednesday, February 19, 2003 6:48 PM
> To: pear-general@lists.php.net
> Subject: RE: [PEAR] MDB: executeQuery() - Error Handling Bug?
>
> Lukas Smith schrieb in php.pear.general:
>
> >> when $mdb->executeQuery() produce an error, the error object don't
> >> contains a callback so a defined
> >> $mdb->setErrorHandler('handle_error'); is not called.
> >>
> >> There is no problem with error handling using other methods like
> >> execute() or queryAll(). I use MDB 1.1.1.
> >>
> >> Here is an error object produced by executeQuery():
> >>
> >> mdb_error Object
> >> (
> >> [error_message_prefix] =>
> >> [mode] =>
> >> [level] =>
> >> [code] => -20
> >> [message] => MDB Error: insufficient data supplied
> >> [userinfo] => Execute query: it was not defined query argument
1
> >> [callback] =>
> >> )
> >
> > Hi,
> >
> > thx for your report.
> > I dont quite understand the issue you are talking about here (I
don't
> > use the setErrorHandler() method). Could you explain in a bit more
> > detail what is happening or not happening. And what needs to happen
> > instead.
>
> $mdb = &MDB::connect($dsn);
> $mdb->setErrorHandler('handle_error');
>
> Now the 'handle_error'-function is automaticly called, if an MDB
method
> produces an error. I use this:
>
> function handle_error($error_obj)
> {
> global $show_debug;
> if ($show_debug) {
> $error_msg = '<span
> class="error"><pre><b>MDB-Error</b><br
/>'
> . $error_obj->getMessage() . '<br />'
> . 'DebugInfo: ' . $error_obj->getDebugInfo()
> . '<br /></pre></span>';
> print $error_msg;
> } else {
> $error_msg = '<p><b>Database Error!</b><br />'
> . 'Please contact the administrator</p>';
> die($error_msg);
> }
> }
>
> This works always as expected and the $error_obj from a MDB method
> contains
> usually [callback] => handle_error.
>
> Only the method $mdb->executeQuery() generate an error_obj with an
empty
> [callback] as shown in the first posting. I think, that is the reason
why
> handle_error() is not called when
>
> $mdb->executeQuery($stmt);
>
> produces an error.
>
> > Also what DB driver are you using.
>
> MySQL
Ok thx.
I will look into it.
However I don't really understand how this could be.
This sort of thing is handled by the code that is inherited by the PEAR
class...
Regards,
Lukas