04-09-2011

Zend Framework using MySQL NOW() expression in Zend db insert statement

To insert the current date / time MySQL offers the convenient NOW() function that can be used in an insert query. To use this same function inside a Zend framework db adapter insert statement you can use the following syntax:

$db = Zend_Db_Table::getDefaultAdapter();
$db->insert('comments',array(
                        'commenttitle' => $params['commenttitle'],
                        'html'=> $html,
                        'creationdate'   => new Zend_Db_Expr('NOW()');
 

Comments:

Your comment:

»

 

[x]