Thursday, October 28, 2010

How to paginate a table with a condition from second association field

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)

Someone know what i'm talking about and maybe have a solution?

Thanks in advance

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 cake-php@googlegroups.com
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?hl=en

No comments: