我确实用这个迁移文件从laravel进行了迁移
<?php
use Illuminate'Database'Schema'Blueprint;
use Illuminate'Database'Migrations'Migration;
class MsCustomer extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('mscustomer', function(Blueprint $table)
{
$table->increments("custid");
$table->string("custname");
$table->string("password");
$table->string("email")->unique();
$table->integer("balance");
$table->string("role");
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('mscustomer');
}
}
然后它成功了,在我的数据库中创建了一个名为"mscustomer"的表,然后我试图通过调用一个模型来使用php手工修补程序,该模型是mscustomer.php,它包含
<?php namespace App;
use Illuminate'Database'Eloquent'Model;
class mscustomer extends Model {
}
然后我得到这个错误"Illuminate''Database''QueryException,消息为'SQLSTATE[42S02]:找不到基表或视图:1146表'twk.mscustomers'不存在……"
我不明白的是,我清楚地创建了mscustomer,但为什么它在后面找"twk.mscustomers"(带"s"),而不是twk.msccustomer。在这种情况下我犯了什么错误吗?
请帮帮我。
注意:很抱歉提问方式不好,这是我第一次在这里提问。
class mscustomer extends Model {
protected $table = 'mscustomer';
}
此外,使用以大写字母开头的类名也是相当标准的。在您的情况下,Mscustomer
(或可能是MsCustomer
)而不是mscustomer