As I discovered in another question, loading 300k rows as entities with Doctrine is not a good idea and will consume at least a gigabyte of memory.
Since I needed some bitwise operations anyway, I figured I'd use a NativeQuery
and iterate()
over the result. However, after the first row, my value is always empty. My code is highly similar to the documentation:
$sql = "SELECT `pushToken` FROM `Devices`";
$rsm = new Doctrine\ORM\Query\ResultSetMappingBuilder(self::$entityManager);
$rsm->addScalarResult("pushToken", "pt");
$query = self::$entityManager->createNativeQuery($sql, $rsm);
$iterableDevices = $query->iterate();
foreach ($iterableDevices as $row)
{
$message->addRecipient($row[0]["pt"]);
}
When I var_dump
'ed $row
however, I noticed that the index is actually incremented each time the code runs through the loop. This is contradicting the documentation. Am I doing something wrong, or have I discovered an honest mistake?