Laravel 5 调用未定义的方法Illumb\Database\Query\Builder::colFunction()
需要向数据库中插入数据我正在使用这个调用Undefine的方法,我现在完全不知道如何定义这个方法 这是路线 Route::post('/colFunction','Controller@colFunction');强> 这是我的控制器功能Laravel 5 调用未定义的方法Illumb\Database\Query\Builder::colFunction(),laravel-5,controller,undefined,sql-insert,Laravel 5,Controller,Undefined,Sql Insert,需要向数据库中插入数据我正在使用这个调用Undefine的方法,我现在完全不知道如何定义这个方法 这是路线 Route::post('/colFunction','Controller@colFunction'); 这是我的控制器功能 function colFunction(Request $req) { $column =$req->input('column'); $data =array('column'=>$column); \DB::table('column')
function colFunction(Request $req)
{
$column =$req->input('column');
$data =array('column'=>$column);
\DB::table('column')->colFunction($data);
}
试试这个代码
在代码中使用insert()而不是colFunction()
function colFunction(Request $req)
{
$column =$req->input('column');
$data =array('column'=>$column);
\DB::table('column')->insert($data);
}
你想做什么?适当解释。错误在这里
->colFunction($data)代码>因为那种类型的函数在数据库查询中不可用,我想向数据库中插入数据我的表名是column,我的列名也是columnok这是为一个函数工作的我有4个这样的函数我该怎么做我该怎么做每个函数我都这么做了现在它说了“(2/2)QueryException SQLSTATE[23000]:完整性约束冲突:1048列“Column”不能为null(SQL:插入列
(列
)值()),因为表中的列
列不为null,这就是原因。始终设置列
列值