And how could I use that object with activedataprovider for gridview widget in yii2?
SELECT `activated_promo`.*
,rides_promo_count_view.count
FROM `activated_promo`
LEFT JOIN `promo_code` `promo` ON `activated_promo`.`promo_id` = `promo`.`id`
LEFT JOIN `users` `customer` ON `activated_promo`.`userID` = `customer`.`ID`
LEFT JOIN rides_promo_count_view ON promo.id = rides_promo_count_view.promo_id
Assuming you have ActiveRecord class for each mysql table, you can use the below query.
//By Assuming you have Active Record for each table
$activedPromo = ActivitedPromo::find()
->select('activated_promo.*','rides_promo_count_view.count')
->leftJoin('`promo_code` `promo`', '`activated_promo`.`promo_id` = `promo`.`id`')
->leftJoin('`users` `customer`', '`activated_promo`.`userID` = `customer`.`ID`')
->leftJoin('rides_promo_count_view', 'promo.id = rides_promo_count_view.promo_id')
->all();
the above way is one of it and for alternatives(for example use joinWith), you can take a look at the document in YII ActiveRecord