Yii 条件 - 修改以包含 OR 条件
Yii criteria - modify to include OR Condition
我有以下代码行执行简单查询
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)
尝试类似的东西
$criteriaOr = new CDbCriteria();
$criteriaOr->addCondition('fulfilled IS NULL', 'OR');
$criteriaOr->addCondition('fulfilled = 0', 'OR');
然后if($this->fulfielled) {$criteria->mergeWith($criteriaOr);}
我有以下代码行执行简单查询
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)
尝试类似的东西
$criteriaOr = new CDbCriteria();
$criteriaOr->addCondition('fulfilled IS NULL', 'OR');
$criteriaOr->addCondition('fulfilled = 0', 'OR');
然后if($this->fulfielled) {$criteria->mergeWith($criteriaOr);}