如何解决此错误传递给 Illuminate\Database\Grammar::parameterize() 的参数 1 必须是数组类型,字符串给定
how to solve this error Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, string given
我在尝试通过将用户输入与数据库中的数据进行比较来获取 ID 时遇到了这个问题。我是新手,我尝试了一些根本没有帮助的解决方案。
下面是我的控制器代码:
public function assign(Request $request)
{
$courselist = new Courselist;
$coursecode = $request->input('coursecode');
$courseid = DB::select("select id from course where course_code = '$coursecode'");
$courselist -> course_id = $courseid;
$courselist -> coordinator = $request->input('coordinatorname');
$courselist -> internal = $request->input('imname');
$courselist -> external = $request->input('exname');
$courselist -> dean = $request->input('deanname');
$courselist -> save();
return back()-> with('alert-success','Data successfully added!');
}
$course = DB::table("your table name")->where("course_code ", "=", $coursecode)->first();
$courselist -> course_id = $course->id;
尝试一下,希望它能奏效。
我在尝试通过将用户输入与数据库中的数据进行比较来获取 ID 时遇到了这个问题。我是新手,我尝试了一些根本没有帮助的解决方案。
下面是我的控制器代码:
public function assign(Request $request)
{
$courselist = new Courselist;
$coursecode = $request->input('coursecode');
$courseid = DB::select("select id from course where course_code = '$coursecode'");
$courselist -> course_id = $courseid;
$courselist -> coordinator = $request->input('coordinatorname');
$courselist -> internal = $request->input('imname');
$courselist -> external = $request->input('exname');
$courselist -> dean = $request->input('deanname');
$courselist -> save();
return back()-> with('alert-success','Data successfully added!');
}
$course = DB::table("your table name")->where("course_code ", "=", $coursecode)->first();
$courselist -> course_id = $course->id;
尝试一下,希望它能奏效。