1

I have the following line of code that does a simple query

if ($this->fulfilled)
   $criteria->addCondition('fulfilled ' . (($this->fulfilled == 1) ? "IS NOT NULL" : "IS NULL"));

How can modify this to do a query that contains an OR command to basically run this query using the framework rather than raw SQL

if ($this->fulfilled)
AND (fulfilled is null OR fulfilled = 0)
Zabs
  • 13,852
  • 45
  • 173
  • 297

1 Answers1

3

Try something like that

 $criteriaOr = new CDbCriteria();
    $criteriaOr->addCondition('fulfilled IS NULL', 'OR');
    $criteriaOr->addCondition('fulfilled = 0', 'OR');

Then if($this->fulfielled) {$criteria->mergeWith($criteriaOr);}