L
L
Lev K2016-05-31 15:39:35
Yii
Lev K, 2016-05-31 15:39:35

How to properly organize a yii2 request?

There are 3 tables, one of them is a linking table.
made this request:

$dr = Driver::find()->joinWith('idTrips')
                            ->where(['not', ['Date_end' => null]])
                            ->all();

idTrips - a getter for linking tables (it works like clockwork)
The problem is that if for any record from the Driver it finds several records from the linked table and they will be like this:
[0] => ['Date_end' => '2014' ],
[1] => ['Date_end' => null],
then the condition where(['not', ['Date_end' => null]]) will work as 'Date_end' => null
I need that if at least one value will be null , then don't take it!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Soshnikov, 2016-05-31
@Leffken

Try like this
['is not', 'attribute', null]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question