首页  >  文章  >  后端开发  >  mysql中的timestamps字段不起作用

mysql中的timestamps字段不起作用

WBOY
WBOY原创
2016-12-01 00:00:391149浏览

为什么我设置了某个字段类型为timestamps,但是他并没有像我预期的一样在更新或者添加的时候自动填充当前时间戳?

还有我用Laravel的migrate生成的数据表也一样,生成的表里面那个timestamps字段根本不起效果。是怎么回事?

这是migration文件

<code><?php use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateEquip extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('equip', function (Blueprint $table) {
            // $table->increments('id');
            $table->smallInteger('equip_id')->unsigned()->comment('装备id');
            $table->string('eqiup_name')->comment('装备名称');
            $table->string('eqiup_desc')->comment('装备描述');
            $table->timestamps();
            $table->primary('equip_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
</code>
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn