I have used this solution: http://www.yiiframew...oc/cookbook/14/
So in my model:
array('DataAtualizado', 'default', 'value' => date('Y-m-d H:i:s'), 'setOnEmpty' => false, 'on' => 'update'),
array('DataInserido, DataAtualizado', 'default', 'value' => date('Y-m-d H:i:s'), 'setOnEmpty' => false, 'on' => 'insert'),
It works ok.
The problem is.
When I find() some model, and update some fields and later save() it, i got this error:
General error: 1292 Incorrect datetime value: '17/09/2009 14:04:26' for column 'DataInserido' at row 1
This occurs because i format my date in afterFind().
One solution for this is to check isNewRecord() inside de beforeSave().
But would be nicer if I can tell to activerecord this: "This field is read only, can be set only the creation not in update. So, ignore this field in update statement".
I wish i was clear!
thanks

Help
This topic is locked











