Hi all,
If there is a way in yii 1.1.7 using CDbCriteria and CActiveDataProvider to make subquery for calculation number of rows in related table in 1 request ? I mean that resulting sql must be:
SELECT ( select count(*) from `bp_tour` where `bp_tour`.`category_id` = `bp_category`.`id` ) as related_tours_count ,
`bp_category`.`id` AS `id`,
`bp_category`.`name` AS `name`,
`bp_category`.`created_at` AS `created_at`
FROM `bp_category` AS `bp_category`
ORDER BY `name` LIMIT 5 OFFSET 0
?