Codeception如何通过数组中的值获取实体

Codeception how to grab entities by values in array

我需要通过数组中的值获取许多实体。

方法如下:

$arrayOfIds = [1,2,3,4,5];
$I->grabEntitiesFromRepository(Product::class, ['id' => $arrayOfIds]);

Return:

[Doctrine\DBAL\Exception\SyntaxErrorException] An exception occurred while executing 'SELECT p0_.id AS id_2, p0_.created_at AS created_at_3, p0_.updated_at AS updated_at_4 FROM product p0_ WHERE p0_.id = ?, ?, ?, ?, ?' with params [1, 2, 3, 4, 5]:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ', 2, 3, 4, 5' at line 1

这是一种方法:

$arrayOfIds = [1,2,3,4,5];
$products = array();
foreach($arrayOfIds as $id){
   $products = array_merge($products, $I->grabEntitiesFromRepository(Product::class, ['id' => $id]));
}

$products 不断通过所有 ID 添加新产品。