How to use MySQL functions when building a query using Zend / PDO

I am using the Zend Framework with the MySQL PDO adapter and I want to use the function in my insert statement. Basically, the SQL I want to generate is as follows:

INSERT INTO `myTable` (`leftId`, `rightId`, `date`) VALUES ($left, $right, NOW()) 

This is the code in my model:

 $data = array( "leftId" => $left, "rightId" => $right, "date" => "NOW()" ); $this->insert($data); 

This is trying to insert "NOW()" , not NOW() :

Common error: 1292 Invalid date and time value: "NOW ()" for the "date" column in row 1

How can I do it?

+4
source share
1 answer

Found in the manual *:

 $data = array( "leftId" => $left, "rightId" => $right, "date" => new Zend_Db_Expr("NOW()") ); 

* I know you can believe it?

+26
source

All Articles