我有以下代码行执行简单查询
if ($this->fulfilled)
$criteria->addCondition('fulfilled ' . (($this->fulfilled == 1) ? "IS NOT NULL" : "IS NULL"));
如何修改它来执行包含OR命令的查询,以基本上使用框架而不是原始SQL运行此查询
if ($this->fulfilled)
AND (fulfilled is null OR fulfilled = 0)
答案 0 :(得分:3)
尝试类似的东西
$criteriaOr = new CDbCriteria();
$criteriaOr->addCondition('fulfilled IS NULL', 'OR');
$criteriaOr->addCondition('fulfilled = 0', 'OR');
然后if($this->fulfielled) {$criteria->mergeWith($criteriaOr);}