Hi James, Doing it with an `array_map()` is actually the right way. Don't try to force weird hydration upon DQL, as it's just going to be hidden magic once you look at it in 3~4 months.
Just iterate and build the resultset as you wanted it. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 17 June 2014 18:47, <[email protected]> wrote: > 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]> 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. > -- 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.
