How to see query created by Zend DB Adapter

For debugging purposes, how do you print the query Zend_DB makes for you. I did not find it in the docs.
For example if I get an sql error when running this code below. how can I dump the statement it is using to help see what I hosed.

$data = array('FNAME' => 'test name',);
$where = "ID = '14'" ;
$n = $db->update("tablename", $data, $where);

Who is Participating?
You can use Zend_Db_Profiler (

Enable the profiler prior to executing your query:


After calling your update() method, you can use the profiler to view the query:

echo $db->getProfiler()->getLastQueryProfile()->getQuery();

You should disable the query profiler when it is not needed as it will create an overhead.

Hope this helps!
mhopkins9901Author Commented:
just what i was looking for
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.