<?php echo Html::anchor('foos/view/'.$foo->id, 'View'); ?> |
class Model_Foo extends Orm\Model { protected static $_properties = array( 'id', 'created_at', 'updated_at', 'name' ); protected static $_observers = array( 'Orm\\Observer_CreatedAt' => array('before_insert'), 'Orm\\Observer_UpdatedAt' => array('before_save') ); }If I comment out the $_observers lines, everything works fine - no errors, but created_at and updated_at remain NULL (obviously). I have tried with a datatype of datetime and timestamp on the created and updated at fields - doesn't seem to make a difference. Using Fuel 1.0 RC2.
class Observer_CreatedAt extends Observer { public static $mysql_timestamp = false; public static $property = 'created_at'; public function before_insert(Model $obj) { $obj->{static::$property} = static::$mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp(); } }Proposed change:
class Observer_CreatedAt extends Observer { public static $mysql_timestamp = false; public static $property = 'created_at'; public function before_insert(Model $obj) { $obj->{static::$property} = static::$mysql_timestamp ? \Date::time()->get_timestamp() : \Date::time()->format('mysql'); } }
It looks like you're new here. If you want to get involved, click one of these buttons!