Active Record Where Not Null

Hi.

I am trying to return results where a field is NOT NULL.

My results come out as expected for IS NULL (see code below).


<?php print_r(Product::find()->where(['parent_id' => null])->all()); ?>

But When I try get results NOT NULL, it doesn’t give me the expected records. (I am trying an exclamation mark).


<?php print_r(Product::find()->where(['parent_id' => !null])->all()); ?>

Any ideas?

Many Thanks!

try:




<?php Product::find()->where('fieldname IS NULL')->all(); ?>



Thanks! And sorry for the late reply. That works. Although, i had to put in NOT NULL for what I wanted, but seems to have done the trick.

MT!