ray*_*n0w 39 php mysql laravel
我尝试使用Laravel 5将数据保存到mysql时出现此错误,其他表单和save()方法工作正常,但这一个:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'sistemal5.cotizacions' doesn't exist (SQL: insert into `cotizacions` (`customer_id`, `total`, `updated_at`, `created_at`) values (1501, 150.69, 2015-05-11 03:16:25, 2015-05-11 03:16:25))
Run Code Online (Sandbox Code Playgroud)
这是我的Controller存储方法:
public function store(CotFormRequest $request)
{
$quote = new Cotizacion;
$quote->customer_id = Input::get('data.clientid');
$quote->total = Input::get('data.totalAftertax');
$quote->save();
}
Run Code Online (Sandbox Code Playgroud)
这是我的模型:
<?php namespace App\Models\Cotizacion;
use Illuminate\Database\Eloquent\Model;
class Cotizacion extends Model {
}
Run Code Online (Sandbox Code Playgroud)
我必须忽略一些非常明显的东西,因为我无法理解为什么Laravel正在添加一个"S"表格是cotizacion而不是cotizacions.
我怎么解决这个问题?
Jam*_*nce 93
我猜Laravel无法确定您用于表名的复数形式.
只需在模型中指定您的表格:
class Cotizacion extends Model{
public $table = "cotizacion";
Run Code Online (Sandbox Code Playgroud)
检查您的迁移文件,也许您正在使用Schema :: table,如下所示:
Schema::table('table_name', function ($table) {
// ...
});
Run Code Online (Sandbox Code Playgroud)
如果要创建新表,则必须使用Schema :: create:
Schema::create('table_name', function ($table) {
// ...
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
102797 次 |
最近记录: |