Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个更新 sql 语句失败,我不知道原因..
有什么问题吗:
<?php extract($_POST); if ($req = $db->prepare("UPDATE {$sTable} SET ? = ? WHERE id=?")) { $req->bind_param("ssi", $columnName, $value, $id ); $req->execute(); } ?>
如果您将列绑定为字符串参数,您的查询将如下所示:
UPDATE some_table SET 'column' = 'value' WHERE id=1
这当然是错误的。所以答案是您不能将列(或表)绑定为准备好的语句中的参数。