execute($st-6ren">
gpt4 book ai didi

php - 按字符串选择表(FROM)

转载 作者:可可西里 更新时间:2023-11-01 06:59:05 25 4
gpt4 key购买 nike

是否可以在 SELECT FROM sql 命令中使用动态值?

Database->prepare("SELECT bomb FROM ? WHERE id=?")
->execute($strTable,$strID);

结果:

Fatal error: Uncaught exception Exception with message Query error: 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...

最佳答案

没有。表名不能作为查询的参数。您需要先构建查询字符串,将表名连接起来。

关于php - 按字符串选择表(FROM),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8609594/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com