I am facing trouble to print query while saving data from my controller file.

I am developing a custom module where I am required to save current date and time when form is submitted. The user is not inputting the date.

$timeStamp = date("Y-m-d H:i:s");
$model->setCreatedTime(Mage::getModel('core/date')->gmtDate(null, $timeStamp ));

Here when I print my $model->getData(); I see created_time value but its not reflecting in DB

Also I tried with below code to print SQL query but it says Call to a member function printLogQuery() on a non-object.

// For printing the whole SQL with the Collection

// For printing only the SQL

How can I print INSERT query for above scenario ?

Pls help


  • have you set timestamp as type for 'created_time' – MeenakshiSundaram R May 17 '14 at 11:45
  • No, for created_time its DATETIME while for updated_time its TIMESTAMP – Mark May 17 '14 at 11:46
  • you could always set the created_time as set on the mysql side of things by setting default CURRENT_TIMESTAMP on the column – David Manners Dec 9 '14 at 13:24

You can follow the advice in the answer here: Print INSERT Query in saveAction

This will guide you to modify Zend_Db_Adapter_Abstract::query() located in lib/Zend/Db/Adapter/Abstract.php... this is a core hack but does work for getting to this query.

Using Z-Ray on Zend Server is much easier, you can see all the queries on any given request without modifying any Magento files. You can try it out: http://serverdemo.zend.com/magento/

Not the answer you're looking for? Browse other questions tagged or ask your own question.