更新时间:2022-01-18 21:23:48
(不幸的是),您不能在准备好的语句中为表名使用参数.您只能将它们用于数据文字.因此UPDATE :surveytable
无效.
(Unfortunately) you can't use parameters for your tablename in your prepared statement. You can only use those for data literals. So UPDATE :surveytable
is invalid.
按照手册:
参数标记只能代表完整的数据文字.两者都不 文字,关键字,也不是标识符或任何任意形式的一部分 可以使用参数来绑定查询部分.
Parameter markers can represent a complete data literal only. Neither part of literal, nor keyword, nor identifier, nor whatever arbitrary query part can be bound using parameters.
当您(完全!!!! )信任您的$tablesnames
来源时,请使用
When you (completely!!!) trust your source of $tablesnames
, use
'UPDATE `' . $tablesnames[i]` . '` SET `postrecords`=:newrecord WHERE `id`=:id'
代替