Note that there are some explanatory texts on larger screens.

plurals
  1. POAssociations with entities (proxy error)
    text
    copied!<p>i've the follow entities:</p> <ul> <li>User</li> <li>Address</li> <li>Country</li> </ul> <p>My user connects to Address and Address to Country. I've a magic __setter and __getter, and when I use <code>$addresses = $user-&gt;__get('addresses');</code>, it retrieves my address(es). </p> <p>dump:</p> <pre><code>array(1) { [0]=&gt; object(stdClass)#463 (13) { ["__CLASS__"]=&gt; string(19) "User\Entity\Address" ["inputFilter"]=&gt; NULL ["addressid"]=&gt; int(21) ["street"]=&gt; string(9) "Lange heg" ["number"]=&gt; int(19) ["addition"]=&gt; string(1) "a" ["zipcode"]=&gt; string(6) "7039CA" ["user"]=&gt; string(16) "User\Entity\User" ["country"]=&gt; string(50) "DoctrineORMModule\Proxy\__CG__\User\Entity\Country" ["creator_id"]=&gt; int(9) ["creation_date"]=&gt; string(8) "DateTime" ["last_modifier_id"]=&gt; NULL ["last_modified_date"]=&gt; NULL } } </code></pre> <p>Only my country don't get the right object (from the country entity). My associations:</p> <p>User-entity:</p> <pre><code>/** * Id from user * * @ORM\OneToMany(targetEntity="User\Entity\Address", mappedBy="user") * @var Address * @access protected */ protected $addresses; </code></pre> <p>Address-entity:</p> <pre><code>/** * @ORM\ManyToOne(targetEntity="User\Entity\User", inversedBy="addresses") * @ORM\JoinColumn(name="user_id", referencedColumnName="user_id", nullable=false, onDelete="cascade") * @var User[] * @access protected */ protected $user; /** * @ORM\ManyToOne(targetEntity="User\Entity\Country", inversedBy="id") * @ORM\JoinColumn(name="country_id", referencedColumnName="id", nullable=false) * @var Country[] * @access protected */ protected $country; </code></pre> <p>Country-entity:</p> <pre><code>/** * Id from a country * * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") * @ORM\OneToMany(targetEntity="User\Entity\Address", mappedBy="country") * @var int * @access protected */ protected $id; </code></pre> <p>In my address entity it stores the user_id and country_id in the database. How can i get my countries from my users? Without returning the proxy?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload