问答详情
源自:4-2 使用DB facade实现CURD

为什么报错呢错误1064

Illuminate\Database\QueryException

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'age) values(?, ?)' at line 1 (SQL: insert into student(name age) values

代码为

<?php
namespace App\Http\Controllers;

use Illuminate\Support\Facades\DB;

class StudentController extends Controller
{
    public function test1(){
      $bool=DB::insert('insert into student(name age) values(?, ?)',['东堂',18]);
      var_dump($bool);
    }
}


提问者:东堂 2020-02-10 19:57

个回答

  • qq_浮生未歇
    2020-02-10 23:50:28

    student(name age)

    name 与 age  间没逗号