views:

85

answers:

1

Hi, I was wondering if there is a way to get a record with all relational data, something like a 'Deep-Fetch'

So if a model Child were related to another model Parent, can we fetch Child & then access Child->Parent->name thru a single query?

Doctrine today fires a query whenever a relationship is accessed. Is this too costly? does it need to be optimizeD?

thanks

+1  A: 

Doctrine automatically hydrates related objects when you select fields from that relations:

Doctrine_Query::create()
  ->select('a.*, c.*)
  ->from('Article a')
  ->innerJoin('Category c');

In this example both Article and Category objects are being hydrated (no additional queries are made).

kuba
thanks Kuba. this means that I will have to write my custom queries, and there is no overload of the fetch() magic method to do this!
Prasad
You mean find* methods? Using them is anyway not advised (performance wise).
kuba