Hi, Thanks for your prompt response!
So I've set up the arbitrary Address and Country entities (as in the example above with no join annotations - code available here http://pastie.org/9299593) and run the following DQL query: SELECT a, c FROM Address a JOIN Country c WITH c.iso2 = a.country_code The result is a mixed result-set with Country and Address entities as entries in a single array. Is there a way to create Address objects with Country objects within them, e.g.: Array ( [0] => Address Object ( [id:Address:private] => 1 [address:Address:private] => address [country_code:Address:private] => GB [country] => Country Object ( [id:Country:private] => 1 [name:Country:private] => United Kingdom [iso2:Country:private] => GB [iso3:Country:private] => GBR ) ) ... ) Really, all I'm looking to do is retrieve a nested result-set, is that possible? Thank you kindly for your help, James. On Tuesday, June 17, 2014 10:31:58 AM UTC+1, Marco Pivetta wrote: > > On 17 June 2014 11:26, <[email protected] <javascript:>> wrote: > >> Is there a fundamental Doctrine reason not to allow arbitrary non-PK >> joins between entities? >> > > You can actually build arbitrary joins via DQL, joining with any condition > you want: > > SELECT f, b FROM Foo f JOIN Bar b WITH f.someField = b.otherField > > It is not possible to build object references through association fields > that don't reference primary keys. That is the case because the ORM tracks > instances via their identifiers in its internal identity map. > When getting a reference to any object that isn't yet loaded, the ORM > needs to build a stub of that object and be able to load it later on (a > proxy). > To keep track of that object and load it, it needs an identifier. > Therefore, your association must include all identifier fields in order to > work correctly within the ORM. > > Marco Pivetta > > http://twitter.com/Ocramius > > http://ocramius.github.com/ > -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
