DQL (doctrine’s language). SELECT, using of 2 tables (2 entities). How to get fields from the result?

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 :frowning: , as usually in the Zend, can’t find the solution. I do not sure in DQL syntax, it’s new for me.

I’m sorry, but Doctrine has nothing to do with the Zend Framework. It is an own project, therefore you will not find anything in documentation of the Zend Framework.

More here: https://www.doctrine-project.org

But I need to add data from another Entity/table:

This is called an “arbitrary join” (see Doctrine ORM documentation about that)