一次调用为啥总插入两条相同数据???
public function add() {
// $result = DB::insert('insert into student(name, age) values(?, ?)', ['xxx', 18]);
// var_dump($result);
$result = DB::table('student')
->insertGetId(['name' => 'mmm', 'age'=>20]);
var_dump($result);
return "StudentController - add";
}我使用 两种方式插入数据, 每次访问一次接口,数据库总是插入两条相同的数据,除了 主键外,其他都相同,是为什么呢?
mysql> select * from student;
+-----+------+-----+-----+------------+------------+
| id | name | age | sex | created_at | updated_at |
+-----+------+-----+-----+------------+------------+
| 108 | mmm | 20 | 0 | 0 | 0 |
| 109 | mmm | 20 | 0 | 0 | 0 |
+-----+------+-----+-----+------------+------------+