Revision #6 has been created by wei on Feb 17, 2009, 11:32:10 AM with the memo:
add new line to remove horizontal scrolling code blocks
« previous (#5) next (#7) »
Automate timestamps in ActiveRecord models
[...]public function rules()
array('title, created, modified', 'required'),
You see the two rules at the end, one changes the modified field when the record's being updated, and the other changes both fields when the record's being created. You'll also see the "new CDbExpression('NOW()')" statement. This passes "NOW()" to the MySQL server and it will not be escaped. MySQL will interpret it as a statement and not as a string. This means that the field types could have been any other date/time type (timestamp, etc.) and it would still work.