I have tried this query but get no results once I add another criteria for the same field (or when aID is set as example below). Can anyone help me correct my query or should I do separate queries and merge the arrays? (I am doing that currently as a work around)
$Criteria = new CDbCriteria();
$Criteria->addCondition("agentid IS NULL");
if (isset(Yii::app()->session['aID'])) {
$Criteria->addCondition("agentid = " . Yii::app()->session['aID']);
}
$amodel = Adverts::model()->findAll($Criteria);