You can do this in a single find() call, using containable. (It will still
create many mysql queries because that's just the way it needs to be done,
however it will filter all the data for you).
Something like:
$this-> Customer ->find('all', array(
'conditions' => array(
'Customer.id' => 1
),
'contain' => array(
'Invoice' => array(
'order' => 'Invoice.created DESC',
'limit' => 2
),
'Credit' => array(
'conditions' => array('Credit.active' => true)
)
)
));
This should fetch the customer info and include that customer's last 2
invoices and all active credits.
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php