0
從插入查詢中刪除從laravel查詢生成器返回的tick。爲什麼Laravel使用插入查詢添加back ticks
$lng= 'a,b,c,d';
DB::table('table')->insert([trim($lng,'`') => $strr]);
Now this query adds back ticks automatically and i can't insert a record.
Output by this query.
insert into `table` (`a,b',c,d`) values('1','2','3','4')
因爲這些反斜槓我得到了這個錯誤信息。
#1136 - 列數並不在行匹配值計數1
如何去除這些反勾,以插入記錄正常
查看[documentation](https://laravel.com/docs/5.5/queries#inserts)==> insert方法接受一個列名和數組的數組提示! – Maraboc
哦,我的天啊,我傳遞字符串值:(@Maraboc –