$builder = $this->modelsManager->createBuilder();
$builder->from('Campaigns');
$builder->join('Clicks', 'Clicks.camp_id = Campaigns.camp_id');
$columns = array(
'Campaigns.network AS network',
'Campaigns.camp_id AS camp_id',
'Campaigns.camp_name AS camp_name',
'Campaigns.package_name as package_name',
'COUNT(Clicks.click_time) AS click_count',
'COUNT(Clicks.install_time) AS install_count',
//'(COUNT(Clicks.click_time)/COUNT(Clicks.install_time)) AS install_rate'
);
$builder->columns($columns);
$builder->groupBy('Campaigns.camp_id, Campaigns.network, Campaigns.camp_name, Campaigns.package_name');
$config = array(
'builder' => $builder,
'limit' => 20,
'page' => $params['page']
);
$paginator = new Phalcon\Paginator\Adapter\QueryBuilder($config);
$page = $paginator->getPaginate();
the $page get the wrong rowcount. and the recorded RAW SQL for rowcount calculating is like below and the result value of it is sure NOT rowcount.
SELECT COUNT(*) AS `rowcount` FROM `campaigns` INNER JOIN `clicks` ON `clicks`.`camp_id` = `campaigns`.`camp_id` GROUP BY `campaigns`.`camp_id`, `campaigns`.`network`, `campaigns`.`camp_name`, `campaigns`.`package_name`
what's wrong?