我有以下协会
用户有很多域
域有很多访问者
域有很多综合浏览量
以下是查询
SELECT
pv.name,pv.domain_id,pv.counter as page_visits, v.ip, v.counter as visits
FROM (
SELECT `domains`.`name` , `pageviews`.`domain_id` , COUNT( `pageviews`.`domain_id` ) as counter
FROM `pageviews`
LEFT JOIN `domains` ON ( `domains`.`id` = `pageviews`.`domain_id`
AND `domains`.`user_id` = '129' )
WHERE `pageviews`.`user_id` = '129'
GROUP BY `pageviews`.`domain_id`
ORDER BY COUNT( `pageviews`.`domain_id` ) DESC
) as pv
LEFT JOIN (
SELECT `domains`.`name` , `visitors`.`ip` , `visitors`.`domain_id` , COUNT( `visitors`.`domain_id` ) as counter
FROM `visitors`
LEFT JOIN `domains` ON ( `domains`.`id` = `visitors`.`domain_id`
AND `domains`.`user_id` = '129' )
WHERE `visitors`.`user_id` = '129'
GROUP BY `visitors`.`domain_id`
ORDER BY COUNT( `visitors`.`domain_id` ) DESC
) as v
ON pv.domain_id = v.domain_id
我想转换成 cakephp 查找分页查询,因为 cakephp 不允许 $this->paginate("mysql query here");