作者:NarratorWang | 来源:互联网 | 2022-11-19 15:54
当我运行我的查询时,我收到此错误
您的SQL语法有错误; 检查与MySQL服务器版本对应的手册,以便在第3行的'select last_insert_id()as productid'附近使用正确的语法
NativeErrorCode编号1064
queryError字符串:
insert into products (systemname, systemversion, created_date)
values ('web andrea', '', now()); select last_insert_id() as productid;
DatabaseName字符串MySQL
DatabaseVersion字符串5.6.10-log
DriverName字符串MySQL-AB JDBC驱动程序
insert into products (systemname, systemversion, created_date) values ('web andrea', '', now()); select last_insert_id() as productid;
我希望数据能够插入但是在这里失败了.
提前致谢
安德里亚
1> Ageax..:
除了@ GMB的评论之外,它出错的原因是因为出于安全原因,默认情况下不允许多个语句 - 以防止sql注入.可以通过添加allowMultiQueries=true
到DSN设置来启用它们.但是,请确保所有查询都使用cfqueryparam来防止sql注入.
话虽如此,您不需要任何一个last_insert_id()
或多个语句.相反,请使用cfquery的"result"属性.插入后,CF yourResultName.GENERATEDKEY
使用新记录ID 填充变量
insert into products (systemname, systemversion, created_date)
values (
,
, now()
)
New ID (yourResultName.GENERATEDKEY) = #yourResultName.GENERATEDKEY#