Thursday, March 31, 2011

Re: Contain and SQL Statement Question

If you have that kind of need you are having database architecture
issues... its not a cakephp issue.

Ask yourself how you do that query in plain SQL.

Cheers

2011/3/31 heohni <heidi.anselstetter@consultingteam.de>:
> 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
>

--
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: