doctrine2 - Associations with entities (proxy error) -
i've follow entities:
- user
- address
- country
my user connects address , address country. i've magic __setter , __getter, , when use $addresses = $user->__get('addresses');
, retrieves address(es).
dump:
array(1) { [0]=> object(stdclass)#463 (13) { ["__class__"]=> string(19) "user\entity\address" ["inputfilter"]=> null ["addressid"]=> int(21) ["street"]=> string(9) "lange heg" ["number"]=> int(19) ["addition"]=> string(1) "a" ["zipcode"]=> string(6) "7039ca" ["user"]=> string(16) "user\entity\user" ["country"]=> string(50) "doctrineormmodule\proxy\__cg__\user\entity\country" ["creator_id"]=> int(9) ["creation_date"]=> string(8) "datetime" ["last_modifier_id"]=> null ["last_modified_date"]=> null } }
only country don't right object (from country entity). associations:
user-entity:
/** * id user * * @orm\onetomany(targetentity="user\entity\address", mappedby="user") * @var address * @access protected */ protected $addresses;
address-entity:
/** * @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;
country-entity:
/** * id 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;
in address entity stores user_id , country_id in database. how can countries users? without returning proxy?
i'm not sure on this, if country, proxy return country entity. have tried fetching country , see kind of object get?
$addresses[0]->__get('country');
Comments
Post a Comment