如何在Doctrine DBAL中使用WHERE IN
子句?
以下查询无效,它搜索名称"Bob","Elvis","Bill"
(作为字符串):
$users = $dbc->fetchAssoc("SELECT * FROM users WHERE name IN(:users_names)", array(
'users_names' => '"Bob","Elvis","Bill"'
));
我尝试使用数组,这是同样的问题。
答案 0 :(得分:0)
试试这个:
$searchParameters = array("Bob","Elvis","Bill");
$users = "SELECT * FROM users WHERE name IN (?1)";
$q = $em->createQuery($users)
->setParameter(1, $searchParameters);
$result = $q->execute();