我想在更新记录时调用此查询而不是ID,但我得到的错误是 columnize()必须是类型数组,字符串给定,调用
$user = Attendances::find(DB::raw('concat (firstname, " ",lastname)'), 'like', Input::get('student_name'))->where('section_name', 'like', Input::get('section_name'))->where('teacher_id', '=', Auth::user()->id)->where('subject_code', 'like', Input::get('subject_code'));
请求帮助:(
答案 0 :(得分:5)
第一种方法也应该是where()
,因为find()
仅适用于主键。最后,还应调用get()
或first()
来执行查询:
$user = Attendances::where(DB::raw('concat (firstname, " ",lastname)'), 'like', Input::get('student_name'))
->where('section_name', 'like', Input::get('section_name'))
->where('teacher_id', '=', Auth::user()->id)
->where('subject_code', 'like', Input::get('subject_code'))
->first();