我应该为 Laravel Eloquent 2 中的 created_at 和 modified_at 使用什么类型的列?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12296087/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What type of column should I use for created_at and modified_at in Laravel Eloquent 2?
提问by brennanag
Should I use DATETEIME? or INT?
我应该使用 DATETEIME 吗?还是INT?
Thanks!
谢谢!
EDIT: I'm specifically addressing the
编辑:我专门针对
public static $timestamps = true;
flag set in Eloquent models.
在 Eloquent 模型中设置的标志。
采纳答案by Jürgen Paul
Laravel only supports datetimefor their timestamps.
Laravel 只支持datetime他们的时间戳。
回答by FireSBurnsmuP
Just as an update: Mich's answeris still valid for Laravel 3 and below,
作为更新:Mich 的回答对 Laravel 3 及以下版本仍然有效,
but as of Laravel 4, it switched to supporting timestampcolumns for created_atand updated_at.
但是从 Laravel 4 开始,它切换到timestamp了created_at和 的支撑柱updated_at。
回答by Stanislav
Laravel 5 defaults is TIMESTAMP
Laravel 5 默认是 TIMESTAMP

