一次調(diào)用為啥總插入兩條相同數(shù)據(jù)???
????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"; ????}
我使用 兩種方式插入數(shù)據(jù), 每次訪問(wèn)一次接口,數(shù)據(jù)庫(kù)總是插入兩條相同的數(shù)據(jù),除了 主鍵外,其他都相同,是為什么呢?
mysql> select * from student;
+-----+------+-----+-----+------------+------------+
| id? | name | age | sex | created_at | updated_at |
+-----+------+-----+-----+------------+------------+
| 108 | mmm? |? 20 | ? 0 |? ? ? ? ? 0 |? ? ? ? ? 0 |
| 109 | mmm? |? 20 | ? 0 |? ? ? ? ? 0 |? ? ? ? ? 0 |
+-----+------+-----+-----+------------+------------+
2018-10-08