Eva Dias
Eva Dias

Reputation: 1747

Query in symfony not working

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

Upvotes: 0

Views: 36

Answers (1)

binarious
binarious

Reputation: 4588

$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()!

Upvotes: 1

Related Questions