On Thu, Oct 28, 2010 at 7:17 AM, ravidp <[email protected]> wrote:
> Hi
>
> In my database i have the following associations:
> Result               hasMany       Measurement
> Measurement    belongsTo     Result
> Result               belongsTo     Chip
> Chip                  hasMany       Result
>
>
> I want to paginate something like the following query:
> SELECT M.*
> FROM measurements M, results R, chips C
> WHERE C.some_field = $value
>
> When I use "contain" to get the chip info its just fetch the info
> about the chip but when i add  a condition about one of the chip's
> fields, cake doesn't recognize chips.
> After digging a little bit, it seems(i'm not sure) that cake fetch the
> info about the chip maually for every row in an initial query(M X R)
> and than attach it to every row so its not doing all at once
> I think that's the reason why cake doesn't recognize the condition
> chips because the first Q doesn't involve chips at all)
>

Have a look here:
http://planetcakephp.org/aggregator/items/3544-using-mysql-inner-join-in-cakephp-pagination

Shame about the dreadful code formatting.

Also, you can use the bindModel() approach:
http://nuts-and-bolts-of-cakephp.com/2008/07/17/forcing-an-sql-join-in-cakephp/

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to