猿问

表已存在但出现错误 SQLSTATE[42S02]:

我正在尝试从 laravel 播种机插入值。插入了所有其他表数据,但我卡在 input_fields 表上。即使它在我的本地 Mamp 服务器上运行也绝对没问题,但是当我尝试在 Live 服务器上运行时出现错误,但正如我所见,我的数据库中存在表名。我也运行“composer dumpautoload”,但仍然面临同样的问题。


输入框.php


namespace App;


use Illuminate\Database\Eloquent\Model;


class inputField extends Model

{

    protected $table = 'input_fields';


    public function dropDown()

    {

        return $this->belongsTo('App\dropDown', 'drop_id');

    }

}

2017_10_13_093801_input_Fields


Schema::create('input_Fields', function (Blueprint $table) {

            $table->increments('id');

            $table->string('field_name');

            $table->string('cat_id');

            $table->string('description');

            $table->string('drop_id')->nullable();

            $table->rememberToken();

            $table->timestamps();

        });

InputFieldsTableSeeder.php


        $inputvalue = new inputField();

        $inputvalue->field_name = 'Bilirubin Total';

        $inputvalue->cat_id = '1';

        $inputvalue->description = '0.0 - 1.2';

        $inputvalue->save();


守着一只汪
浏览 248回答 1
1回答

哈士奇WWW

你和字母大小写有点不一致。$table = 'input_fields'和create('input_Fields', ....不同的环境/配置可以有不同的表名区分大小写设置。尝试并保持一致并更改为create('input_fields', ...)它应该工作得更好。
随时随地看视频慕课网APP
我要回答