Search code examples
doctrinesymfony-1.4dql

multiple where condition for checking NULL value in symfony1.4 and doctrine


I am using symfony1.4 and doctrine. I need to check a condition where the value is NULL. I nedd to write a query where status = 1 and start=NULL and end= NULL and estimated_time != NULL .I have tried with this but i am not able to get the result.

            $tickets = Doctrine_Core::getTable('table')
              ->createQuery('a')
              ->where('status=?','1')
              ->andWhere('start=?', '')
                              ->andWhere('end=?', '')
              ->andWhere('estimated_time!=?','')
              ->orderBy('id DESC');

any help will be greatly appreciated.Thank You..


Solution

  • Try using IS NOT NULL:

    $tickets = Doctrine_Core::getTable('table')
        ->createQuery('a')
        ->where('status=?','1')
        ->andWhere('start IS NOT NULL')
        ->andWhere('end IS NOT NULL')
        ->andWhere('estimated_time IS NOT NULL')
        ->orderBy('id DESC');