In my Controller was DQL Select:
$query = $this->entityManager->createQuery("SELECT cat
FROM Application\Entity\Catalog cat
WHERE cat.parent_id IS NULL AND cat.name IN (:names_ar)");
$query->setParameter('names_ar', $equipment_categories);
$catalog = $query->getResult();
Working greate! But I need to add data from another Entity/table:
$query = $this->entityManager->createQuery("SELECT cat, con
FROM Application\Entity\Catalog cat, Application\Entity\Content con
WHERE cat.parent_id IS NULL
AND cat.name IN (:names_ar)
AND cat.id = con.id");
I have connection of this tables in Entity:
/**
* @ORM\Id
* @Gedmo\TreePathSource
* @ORM\Column(type="string");
* @ORM\OneToOne(targetEntity="Content")
* @ORM\JoinColumn(name="id", referencedColumnName="id")
*/
protected $id;
And second variant with JOIN:
$query = $this->entityManager->createQuery("SELECT cat, con.sign
FROM Application\Entity\Catalog cat
INNER JOIN Application\Entity\Content con
WHERE cat.parent_id IS NULL
AND cat.name IN (:names_ar)");
Variants working without errors. But before I was taking data by
$catalog->fieldname;
Now last code not working. I do var_dump() of $catalog: 5-10 meters of data on my screen , as usually in the Zend, can’t find the solution. I do not sure in DQL syntax, it’s new for me.