I'm trying to paginate my robots filtering the data with two named
parameters in the url.

In the controller I build the paginate var manually (and i think that
with no errors), but, when paginating, the contain doesn't work and no
data is retrieved.

The paginate var, obtained with $this->set('paginate',$this-
>paginate); at the controller and debug($paginate); in the view, looks
that way:

Array
(
    [Robot] => Array
        (
            [limit] => 4
            [contain] => Array
                (
                    [0] => Rating
                )
            [fields] => Array
                (
                    [0] => Robot.*
                    [1] => AVG(Rating.rating) AS average_rating
                )
            [order] => Array
                (
                    [average_rating] => desc
                )
            [conditions] => Array
                (
                    [Rating.created >] => 2009-02-03
                    [Robot.is_public] => 1
                )
        )
    [RobotComment] => Array
        (
            [order] => Array
                (
                    [RobotComment.created] => desc
                )
            [limit] => 4
        )
)

I think the build is correct, but I got this sql errors:

SELECT `Robot`.*, AVG(`Rating`.`rating`) AS average_rating,
`Robot`.`id` FROM `robots` AS `Robot` WHERE `Rating`.`created` >
'2009-02-03' AND `Robot`.`is_public` = 1 ORDER BY `average_rating`
desc LIMIT 4

I know that the use of avg is incorrect, but the point is why the
table rating is not in the FROM clausule and there are no joins. Once
contain works, I will manage the avg problem.

The complete code, with model relations and the paginate build process
is here: http://bin.cakephp.org/saved/43314
--~--~---------~--~----~------------~-------~--~----~
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