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);

mhopkins9901Asked:
Who is Participating?
 
tkcinCommented:
You can use Zend_Db_Profiler (http://framework.zend.com/manual/en/zend.db.profiler.html).

Enable the profiler prior to executing your query:

$db->getProfiler()->setEnabled(true);

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!
0
 
mhopkins9901Author Commented:
just what i was looking for
0
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.