最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號安全,請及時綁定郵箱和手機立即綁定

一次調(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ù), 每次訪問一次接口,數(shù)據(jù)庫總是插入兩條相同的數(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 |

+-----+------+-----+-----+------------+------------+


正在回答

1 回答

你這里添加一次了??$result?=?DB::table('student')?->insertGetId(['name'?=>?'mmm',?'age'=>20]);

?return?"StudentController?-?add";這里又一次;所以是兩次
0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

一次調(diào)用為啥總插入兩條相同數(shù)據(jù)???

我要回答 關注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號