1

如何在WHERE INDoctrine DBAL 中使用子句?

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

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

我尝试了一个数组,这是同样的问题。

4

1 回答 1

0

尝试这个 :

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

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

    $result = $q->execute();
于 2014-03-22T18:16:56.307 回答