Monday, 15 June 2015

Specifying index with Symfony2 for Doctrine's PersistentCollection -



Specifying index with Symfony2 for Doctrine's PersistentCollection -

can tell me how can configure symfony2/doctrine index objects within persistentcollection, specified column in entity?

for illustration assume have 2 tables; categories , products, many products 1 category. when utilize repository load category, , phone call getproducts() load products, want them returned indexed product id, or whatever column specify. they're indexed incrementally zero.

is there anyway this, or need loop through , manually set keys myself?

mapping onetomany associations allows define indexby property. annotation mappings, following

class category { // ... /** * @onetomany(targetentity="products", indexby="productid", mappedby="product") */ protected $products; // ... }

xml, yaml , php mappings allow too, , works manytomany.

symfony2 doctrine

No comments:

Post a Comment