Thursday, March 31, 2011

Contain and SQL Statement Question

Hi,

I have the following models:

Member hasMany Payments
Payment belongs to a member

To get now all members and their payments I do the following
statement:

$this->paginate = array(
'fields' => array(.....),
'conditions' => array(...),
'contain' => array(
'Payment' => array(
'fields' => array(...),
'conditions' => array(...)
)
)
);

So far, the result is correct.

BUT!
The second statement, where all payment are getting selected, that
statement looks like:
WHERE `Payment`.`member_id` IN (5, 10, 11)

This is for 3 members fine, but what will happen, if I have 10k
members?

Do I have the chance to get this whole statement done in 1 single
statement? To make sure I will not fail in perfomance in the future?

Please advice!
Thanks!!

--
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: