Monday, November 3, 2008

AW: Pagination with HasMany and SQL Aggregation

Hi, that sounds like pagination with conditions:

http://groups.google.ch/group/cake-php/msg/09277228f45365ac


If I understood you correctly: if you want an average rating you have to read first all your datasets and loop though the array and create an average value of the ratings. So paging won't help there.

Anja


-----Ursprüngliche Nachricht-----
Von: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] Im Auftrag von mwcbrent
Gesendet: Dienstag, 4. November 2008 05:21
An: CakePHP
Betreff: Pagination with HasMany and SQL Aggregation


I'm not sure that this is possible but if it is, it would put Cake into a special place in my heart. I have 2 related models Articles and Ratings.

Articles hasMany Ratings

A Rating has a User ID an Article ID and a Rating #. In order to get an articles rating I need to query all ratings by the Article ID and average them out.

How would I paginate all Articles ordered by Rating?


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