我有查询是动态更新到一个迁移文件,当我执行确切的查询它会抛出这个错误,我已经尝试了很多,但没有任何工作! Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type':'text','filed_name':'Ture_st aare','order':'5','values':['Mr','Mrs','Miss']' at line 1
这些查询有什么区别?
Query 1
// working
DB::statement("Insert Into custom_fields_configure (`table_name`, `configure`, `filed_name`, `module_id`,`created_at`,`updated_at`) values ('ads','test','cf_Ture_staare',22,now(),now());");
Query 2
// Not working
DB::statement("Insert Into custom_fields_configure (`table_name`, `configure`, `filed_name`, `module_id`,`created_at`,`updated_at`) values ('ads','{'type':'text','filed_name':'Ture_staare','order':'5','values':['Mr','Mrs','Miss'],'datalenght':'5'}','cf_Ture_staare',22,now(),now());");
这怎么解决?
您似乎在一个字符串中使用了单引号作为一个值。只需加倍单引号,这样SQL就能正确解释它们。 –
只需在“'”前添加“\”或用双引号替换单引号 – Beginner
是的,它的作品对我来说,谢谢! @GordonLinoff,@ Newbee Dev –