Free Android CakePHP GMaps Articles by Bali Web Design

May 25, 2011

Saving Mysql Function Now on Cakephp

Filed under: cakephp,php — admin @ 3:45 am

I think many cakephp programmer will get confuse when they want to save column/field on table with mysql function such as NOW(), CURDATE(), etc, We cannot use simple way of the saveField method or save method on model object.

This code will not save the data field into current date time on mysql.

$this->ModelName->saveField('date_field', 'NOW()');


$data['ModelName']['id'] = 1;
$data['ModelName']['date_field'] = 'NOW()';

It will not work as you want. Because cakephp will ada quote on the value.