Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 大型自动增量ID_Php_Mysql_Laravel_Auto Increment - Fatal编程技术网

Php 大型自动增量ID

Php 大型自动增量ID,php,mysql,laravel,auto-increment,Php,Mysql,Laravel,Auto Increment,我对桌上的一些auto inc ID有一个奇怪的问题,它不是每次增加1,而是每次增加10 我在用电话 用于Heroku的ClearDB MySQL插件 PHP 5.5.15 Apache 2.4.10 拉拉维尔发展分部(4.2) 我已经通过artisan的迁移功能创建了数据库,我对数据库表的迁移是 <?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration;

我对桌上的一些auto inc ID有一个奇怪的问题,它不是每次增加1,而是每次增加10

我在用电话

  • 用于Heroku的ClearDB MySQL插件
  • PHP 5.5.15
  • Apache 2.4.10
  • 拉拉维尔发展分部(4.2)
我已经通过artisan的迁移功能创建了数据库,我对数据库表的迁移是

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCheckinTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('checkins', function(Blueprint $table)
        {
            $table->increments('id');

            $table->integer('visitor_id');
            $table->integer('meeting_id');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('checkins');
    }

}
签入类看起来像

<?php

class Checkin extends Eloquent {

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'checkins';

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = array('updated_at', 'visitor_id');

    protected $fillable = array();

    public function meeting(){
        return $this->hasOne('Meeting','id', 'meeting_id');
    }

    public function client(){
        return $this->hasOne('Visitor','id','visitor_id');
    }

}
id  visitor_id meeting_id updated_at created_at

1   1   0   2014-08-04 21:25:25 2014-08-04 21:25:25
11  1   0   2014-08-04 21:35:54 2014-08-04 21:35:54
21  1   0   2014-08-04 21:35:57 2014-08-04 21:35:57
31  1   0   2014-08-04 21:35:59 2014-08-04 21:35:59
41  1   0   2014-08-04 21:36:01 2014-08-04 21:36:01
51  1   0   2014-08-04 21:36:03 2014-08-04 21:36:03
正如您所看到的,id每次都会增加10,而不是1

如果有人知道原因,请告诉我:)


非常感谢

作为对其他遇到此问题的人的回答

之所以要迈出这么大的一步,是因为ClearDB实现了MySQL配置

他们这样做的理由如下:(谢谢Razor)

如果需要自己调查增量设置,可以运行以下查询

SHOW VARIABLES LIKE 'auto_inc%';
这将输出如下内容

auto_increment_increment    10
auto_increment_offset   1
所以你可以看到我跳的原因是因为它被设置为10

正如@Juergen d所说,如果需要,您应该能够通过以下查询来更改此设置

SET @@auto_increment_increment=1
SET GLOBAL auto_increment_increment=1;
然而,我没有改变这个设置,因为ClearDB设置它是有原因的,我只是在我配置错误的情况下查询这个设置


案例结束,感谢大家的投入。

尝试设置
SET@@auto\u increment\u increment=1
SET全局auto\u increment\u increment=1@Razor啊brill,我想这就解释了为什么会发生这种情况,我完全认为是我的代码导致了这个问题!所以我想应该可以保持原样了?这是DBA用来增加自动增量偏移量的常用技术。简短回答-是的,如果你保持原样就可以了。auto_increment的工作只是唯一地标识一行,所以保留它没有什么错。感谢大家的输入,我在下面为其他任何经历过这种情况的人添加了一个答案。
SET @@auto_increment_increment=1
SET GLOBAL auto_increment_increment=1;