2008年7月30日星期三

Re: [fw-db] SQL debug please

monk.e.boy wrote:
>
> I'd like to debug queries that are causing exceptions (i.e. my SQL is
> broken) how do I see the SQL that is being generated here?
>

You may have to fetch "unfinished" query profiles. This feature never got
documented. Here's how to use it:

$db->getProfiler()->setEnabled(true);
try {
// ...execute broken SQL statement...
} catch (Zend_Db_Exception $e) {
foreach ($db->getProfiler()->getQueryProfiles(null, true) as $prof) {
print $prof->getQuery() . "\n";
}
}

The first argument to getQueryProfiles() is for the query type (or null for
all types). The second argument is a boolean which defaults to false. If
it's true, the function includes unfinished queries as well as finished
queries in the array returned.

Regards,
Bill Karwin
--
View this message in context: http://www.nabble.com/SQL-debug-please-tp18728846p18736902.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: