Assigning the same parameter value multiple times in pdo execute

十年热恋 提交于 2019-12-02 05:05:26

Using PDO you have the ability to use named parameters, however in your question you want to use 1 parameters for multiple values and that means emulation has to be on:

$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);

Now you can do the following:

$stmt = $db->prepare("SELECT * FROM table WHERE userid = :userid AND userid = :userid");

$stmt->excecute([
  ':userid' => 1
]);

Resulting in:

"SELECT * FROM table WHERE userid = 1 AND userid = 1"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!