fetchA-6ren">
gpt4 book ai didi

mysql - WHERE IN 与 Doctrine 2 DBAL

转载 作者:行者123 更新时间:2023-11-30 23:04:09 24 4
gpt4 key购买 nike

如何在 Doctrine DBAL 中使用 WHERE IN 子句?

以下查询不起作用,它搜索名称 "Bob","Elvis","Bill"(作为字符串):

$users = $dbc->fetchAssoc("SELECT * FROM users WHERE name IN(:users_names)", array(
'users_names' => '"Bob","Elvis","Bill"'
));

我试过数组,还是一样的问题。

最佳答案

试试这个:

 $searchParameters = array("Bob","Elvis","Bill");

$users = "SELECT * FROM users WHERE name IN (?1)";
$q = $em->createQuery($users)
->setParameter(1, $searchParameters);

$result = $q->execute();

关于mysql - WHERE IN 与 Doctrine 2 DBAL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22581260/

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