0

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.

Znk
  • 29
  • 7
  • AFAIK should work fine. Are you sure that notice is related to this part of code? – u_mulder Oct 14 '20 at 09:38
  • Yes. its from this part. WHERE a.number IN (?)' with params [["3286340600316","3286340619912","3286340641418","3286340883818", ...........]] – Znk Oct 14 '20 at 09:40
  • is a typo too, should be `->setParameter('numbers', $numbers)` not `$str` – Lawrence Cherone Oct 14 '20 at 10:09
  • @Lawrence Its not type error.... I have tried `$numbers` which is an array. It returns me Notice error. Then I convert array to string `$str`. This is returning empty records. – Znk Oct 14 '20 at 10:17

0 Answers0