views:

31

answers:

1

What happens when two models are associated with a belongsTo and a hasOne relationship at the same time?
Does the framework detect this situation to avoid retrieving too much data?

EDIT: CakePHP specifically, although what other frameworks do would be helpful, too.

A: 

Most frameworks do lazy loading of data, that is, data is retrieved only when the object property is accessed.

stillstanding
So most frameworks would work fine with this unless I tried something like a `print_r()` ?
chustar
if print_r() is limited to a single record, then only that record will be retrieved. on the other hand, if print_r() tries to display a relationship, behind the scenes, the pdo cursors of all relevant associated objects will activate and retrieve the necessary data. i sure hope you're not using print_r() for a large multi-dimensional array of objects.
stillstanding