Answer the question
In order to leave comments, you need to log in
What's wrong with the date selection?
Why is sampling not taking place?
actions table
id | client_id | update_time
1 | 69 | 2018-01-03 03:04:37
2 | 69 | 2021-03-17 00:38:38
$query = Client::find()
->joinWith(['actions', 'companies', 'manager'])
->andWhere(['<=', 'actions.update_time', $date->format('Y-m-d H:i:s')])
->andWhere(['!=', 'clients.status', 2])
->groupBy('clients.id');
var_dump($query->createCommand()->getRawSql());
SELECT `clients`.* FROM `clients`
LEFT JOIN `group_actions` `actions` ON `clients`.`id` = `actions`.`client_id`
LEFT JOIN `group_companies` `companies` ON `clients`.`id` = `companies`.`client_id`
LEFT JOIN `users` `manager` ON `clients`.`manager_id` = `manager`.`id`
WHERE (`actions`.`update_time` <= '2019-09-18 10:54:38') AND (`clients`.`status` != 2)
GROUP BY `clients`.`id`
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question