How to pass an array into the IN statement in doctrine raw query?

45 views Asked by At

I have an array numbers.

$numbers  =  [
        "3286340600316",
        "3286340619912",
        "3286340641418",
        "3286340883818",
        "3286340960618",
    ];

$connection = $this->entityManager->getConnection();

$result = $connection->createQueryBuilder()
    ->select('a.specification')
    ->from('article', 'a')
    ->innerJoin('a', 'ware', 'b', 'a.articleId = b.articleId')
    ->andWhere('a.number IN (:numbers)')
    ->setParameter('numbers', $str)
    ->execute()->fetchAll();

When I pass array directly to the query, it returns 'Notice: array to string conversion'.

So I implode the array into string;

$str = implode(',',$numbers);

When I pass $str, it returns empty records. It is not supposed to return empty.

Can anybody help me what I am doing wrong here.

Thank You.

0

There are 0 answers