Laravel:查询异常

时间:2017-10-26 05:34:11

标签: php sql database laravel-5.3

  

数组到字符串转换(SQL:插入RegisterStudentLRN,   dateOfBirthsexupdated_atcreated_at)值(1234,   1996-02-10,女,2017-10-26 05:30:32,2017-10-26 05:30:32))

enter image description here

StudentController商店内容

public function store(Request $request){

     //validation
    $this->validate($request, [
        'LRN' => 'required|max:100',
    ]);

    $student = New Student;
    $student->LRN = $request->input('LRN');
    $student->dateOfBirth = $request->input('dateOfBirth');
    $student->sex = $request->input('sex');

    $student->save();

    return redirect()->back();
}

1 个答案:

答案 0 :(得分:1)

更改以下内容:

$student->sex = $request->input('sex')[0];

输入似乎是一个数组,所以你需要[0]的值 或删除输入名称中的[]以在php $request->input('sex')

中使用