D
D
Dos2020-03-18 14:00:47
Python
Dos, 2020-03-18 14:00:47

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

Sample date: 2019-09-18 10:54:38
PHP
$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());

SQL
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`

What is wrong in my code? Lines with 2020 fall

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
techkuz, 2019-08-16
@antosha_html

file.write(your_string + '\n')

I
idShura, 2020-03-18
@pro-dev

Doesn't bother you?

WHERE (`actions`.`update_time` <= '2019-09-18 10:54:38')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question