I
I
Ivan Antonov2015-03-19 13:15:10
symfony
Ivan Antonov, 2015-03-19 13:15:10

How to set external link in Doctrine?

Now it works like this:

$query = $this->getEntityManager()->createQueryBuilder()
    ->from('AppBundle:Offers', 'offer')
    ->leftJoin('AppBundle:OffersImages', 'image', 'WITH', 'image.offer=offer.id');

How to correctly describe the entities so that the last line does not need to describe the condition for selecting images image.offer=offer.id?
There are no mentions of the OffersImages entity in Offers.
and in OffersImages there is an Offers identifier:
<?php /* ... */
    /**
     * @var \AppBundle\Entity\Offers
     *
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Offers")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="offer_id", referencedColumnName="id")
     * })
     */
    private $offer;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2015-03-19
@antonowano

Create a one-to-many-bidirectional bidirectional relationship .
The managing side you have is OffersImages.
The doctrine will not create an additional field in the Offers table, for that there will be a two-way mapping.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question