开发者

Getting FuelPHP observers to use MySQL datetimes

I was trying to get the FuelPHP ORM Observers to us开发者_JAVA技巧e MySQL datetimes rather than unix timestamps, however I can't figure out how to use the code provided in the docs.

They provide this code: Orm\Observer_CreatedAt::$mysql_timestamp = true;

But where do I use this? In the model? It doesn't seem to work there.

Thanks!


This is something that was put in a bit hacky and should have been a config value from the beginning, something we'll fix for 1.1.

Best way to do it right now is probably to give the models using the CreatedAt/UpdatedAt observers an _init() method like the code below. The init method is called by the autoloader after loading the class.

public static function _init()
{
    Orm\Observer_CreatedAt::$mysql_timestamp = true;
    Orm\Observer_UpdatedAt::$mysql_timestamp = true;
}

Btw asking a question on our forums or on IRC will probably get you faster answers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜