0

I have a query in the model of my table: $q = $this->createQuery('a') ->where('a.img1 = null') ->orderBy('a.created_at DESC') ->limit(4); The thing is that it returns nothing, but in DB there is an entry with no image (img1 field is null). What am I doing wrong? thank you

1 Answer 1

1
$q = $this->createQuery('a')
          ->where('a.img1 IS NULL') // It needs to be IS NULL instead of = null
          ->orderBy('a.created_at DESC') 
          ->limit(4);

Don't forget ->execute()!

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much... it's working fine now! I forget the $q->execute(); on the question but I had it in the code already:)
Yep, I forget it often, too! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.