i want to store row creation or modification time each time new model instance is created and stored in database.
does yii provide any standard combination to store current time and retrieve it later when showing on the page.
do i have to use NOW() to store the current time…?
what class or display method is there to show this stored time on the page…?
You should add the timestamp field to your database.
Before saving, do:
$model->modified= new CDbExpression('NOW()');
The CDbExpression will avoid quotation of your expression
created int(11) NOT NULL DEFAULT ‘0’,
changed int(11) NOT NULL DEFAULT ‘0’,
already defined in my database
i am using this expression
$model->created = new CDbExpression(‘NOW()’);
just before calling save()
this gives an error
"Created must be an integer."
Those field should be timestamp, not integer.
If you want integer, you can do something like:
$model->created = strtotime('now');
But in database you will see an interger, not a nice timestamp.