I am having problem in getting data from doctrine object. When I use findOne(id) and try to access any variable like $result->getVariable() it works fine. But as soon as I use doctrine query builder and add some conditions, it says
Attempted to call method "getVariable" on class "Doctrine\ORM\QueryBuilder....
My Code is
foreach ($Ids as $Id) {
$result = $em->createQueryBuilder()->select("s")
->from("Entity", "s")
->where('s.id = :s_id')
->setParameters(array('s_id'=>$Id));
if($category)
{
$result->innerJoin('s.cat','c');
$result->where("c.primaryClassification = :category");
result->setParameter('category',$category);
}
}
The Code which is working is
foreach ($Ids as $Id) {
$em->getRepository("Entity")->findOneById($Id);
}
I think it is the difference in data returned because of different types of methods used.
Thanks in advance!