[DDC-2375] Join with multiples tables Created: 27/Mar/13  Updated: 27/Mar/13  Resolved: 27/Mar/13

Status: Closed
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: New Feature Priority: Major
Reporter: Adriano Crivelari Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: None


Dear Friends, I've a question about Join with multiple tables.
I've 3 tables: Country, State, City, and I need get country_name from City Entity.
Any suggestion?

Table City:

Table State

Table Country

This is my Entity City:


namespace System\Entity;

use Doctrine\ORM\Mapping as ORM,


    class SysCity
    Instantiate all methods gets and sets

public function __construct($options = null)
{ Configurator::configure($this, $options); }


    @var integer
    @ORM\Column(name="id_city", type="integer", nullable=false)
    private $idCity;


    @var string
    @ORM\Column(name="city", type="string", length=255, nullable=false)
    private $city;


    @var \SysState
    @ORM\ManyToOne(targetEntity="System\Entity\SysState", inversedBy="state")
    @ORM\JoinColumns( { * @ORM\JoinColumn(name="id_state", referencedColumnName="id_state") * }

    private $idState;


    @var \SysCountry
    @ORM\ManyToMany(targetEntity="System\Entity\SysCountry", inversedBy="country")
    joinColumns= {@ORM\JoinColumn(name="id_state", referencedColumnName="id_state")}

    inverseJoinColumns= {@ORM\JoinColumn(name="id_country", referencedColumnName="id_country")}
    private $idCountry;

public function getIdCity()
{ return $this->idCity; }

public function setIdCity($idCity)
{ $this->idCity = $idCity; return $this; }

public function getCity()
{ return $this->city; }

public function setCity($city)
{ $this->city = $city; return $this; }

public function getIdState()
{ return $this->idState; }

public function setIdState($idState)
{ $this->idState = $idState; return $this; }

public function getIdCountry()
{ return $this->idCountry; }

public function setIdCountry($idCountry)
{ $this->idCountry = $idCountry; return $this; }

Thanks a lot!

Comment by Marco Pivetta [ 27/Mar/13 ]

This is an issue tracker, not a support forum. Please ask your questions on the http://groups.google.com/group/doctrine-user mailing list or on http://stackoverflow.com/ or on IRC on irc://irc.freenode.net#doctrine

Generated at Sun Aug 30 12:10:57 EDT 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.