我对cakeHP分页有问题,特别是当我执行左联接时。返回了6行,在分页限制为3的情况下,它应该计算2页,但它计算3页,最后一页为空。以下是我传递给paginate的选项数组:
Array ( [fields] => Array ( [0] => DISTINCT Video.id, Video.thumbnail_img, Video.title, Video.description, Video.tags, Video.views, Video.date, (( SELECT COUNT(Rating.id) FROM ratings AS Rating WHERE Rating.rating = 1 AND Rating.video_id = Video.id ) - ( SELECT COUNT(Rating.id) FROM ratings AS Rating WHERE Rating.rating = 0 AND Rating.video_id = Video.id ) ) AS avgRating ) [joins] => Array ( [0] => Array ( [table] => ratings [alias] => Rating [type] => LEFT [conditions] => Array ( [0] => Rating.video_id = Video.id ) ) ) [order] => Array ( [avgRating] => DESC ) )
你知道为什么会发生这种事吗?我不确定是否有其他方法可以在不使用联接的情况下获得我想要的结果,但我打赌这就是问题的原因。
如有任何建议,我们将不胜感激。谢谢