How to insert into a table with NOW() in pdo_mysql

103 Views Asked by At

I am trying to use mysql NOW() function when I insert a record with Zend_Db but it is not working it seems. //$transaction is a very normal Zend_Db_Table object

$transaction->insert(array('date_created' => 'NOW()')); //inserted 0000-00-00 00:00:00

$transaction->insert(array('date_created' => '2010-12-12 12:12:12')); //inserted 2010-12-12 12:12:12

I am pretty sure I could do it using

$transaction->query()

But was wondering what was wrong with my first approach. Also NOW() does work on the server when in phpmyadmin.

All this on ubuntu server.

1

There are 1 best solutions below

3
On BEST ANSWER

Try new Zend_Db_Expr('NOW()') instead of the string NOW()