Re: MDB2 best way to get detailed errors back
| From: | Lukas Smith | Date: | Wed, 19 Jul 2006 16:24:25 +0000 |
| Subject: | Re: MDB2 best way to get detailed errors back | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-24703@lists.php.net to get a copy of this message | ||
Mark Steudel wrote:
Hi there, I've been switching my apps from DB to mdb2 and I had a little function that I used to spit out the error messages when I did something wrong: function mysqlErrorCheck ($res, $line = '', $debuglevel = 0) { if (PEAR::isError($res)) { switch ($debuglevel) { case "1": echo '<pre>DBMS/Debug Message: ' . $res->getDebugInfo() . "</pre>\n"; case "0": $msg .= 'MYSQL DEBUG INFORMATION'; $msg .= $res->getDebugInfo(); $msg .= 'SESSION VARIABLES'; $msg .= print_r( $_SESSION, true ); $msg .= 'POST VARIABLES'; $msg .= print_r( $_POST, true ); $msg .= 'SERVER VARIABLES'; $msg .= print_r( $_SERVER, true); mail('mark-list@netriver.net', $_SERVER['HTTP_HOST'].' MySQL error', $msg ); die($res->getMessage().' line: '.$line); break; } } } Before it used to spit out the sql, and now it doesn't, should I access the last_query variable in the mdb2 result? Or is there some better way to do something like this. I just want to see what the sql server is saying.Not really by default. You can tweak your error handling and debugging with a custom debug handler however. Every query and several other methods trigger a debug callback that you can define. There is no detailed documentation of this yet, however I explain it a bit in a blog post of mine, and I am using it inside the SQL generator of LiveUser: http://pooteeweet.org/blog/312 regards, Lukas