Home > Backend Development > PHP Tutorial > timestamps field in mysql not working

timestamps field in mysql not working

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-03-01 14:14:01
Original
1220 people have browsed it

Why did I set a field type to timestamps, but it did not automatically fill in the current timestamp when updating or adding as I expected?

The same goes for the data table I generated using Laravel's migrate. The timestamps field in the generated table has no effect at all. what's going on?

This is the migration file

<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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template