Wednesday, January 4, 2012

Zend db examine SQL query -- Profiler

You can use Zend_db_profiler to capture and examine the sql queries or statements that Zend db adapter forms and executes. example:

$db->getProfiler()->setEnabled(true);
$db->update($data, array('id = ?' => $Posts->id));
print $db->getProfiler()->getLastQueryProfile()->getQuery();
print_r($db->getProfiler()->getLastQueryProfile()->getQueryParams());
$db->getProfiler()->setEnabled(false);
 
 
it's important to set the profiler's enabled property to false (last line) after using it as it uses up resources and slows down database transactions.


source: http://stackoverflow.com/questions/1009639/zend-db-framework-examine-query-for-an-update
 

No comments:

Post a Comment