Reputation: 33644
I have the following command:
$rsm = new ResultSetMapping();
$query = $this->em->createNativeQuery('SELECT userid FROM prospective_shop WHERE LENGTH(bio) = 0 ORDER BY RAND()', $rsm);
//$query->setMaxResults(10);
$prospectiveShops = $query->getResult();
here it gives me an empty array. I copy pasted that SQL and it worked perfectly fine. Any idea why?
Upvotes: 0
Views: 833
Reputation: 5599
Haven't you forgotten to use:
$rsm->addFieldResult(...);
to map results of the query to the doctrine object?
EDIT:
try this way:
$rsm = new ResultSetMapping();
$rsm->addEntityResult('my\bundle\Entity\ProsprectiveShop', 's');
$rsm->addFieldResult('s','userid','userid');
$query = $this->em->createNativeQuery('SELECT userid FROM prospective_shop s WHERE LENGTH(bio) = 0 ORDER BY RAND()', $rsm);
$prospectiveShops = $query->getResult();
Upvotes: 1