This exception is thrown in CActiveFinder::getColumnSelect .
When CDbCriteria::$select is a string, it is treated as a simple list of comma-separated columns. Your expression is interpreted as two different columns. You can get around this by setting select to the array yourself - in this case, comma separation is not performed 1 :
$criteria = new CDbCriteria(); $criteria->select = array("DATE_ADD(NOW(), INTERVAL 5 DAY) AS datetime_limit"); $models = Users::model()->findAll($criteria);
Please note that if you write an alias that does not match the public model object or the database field, it will be retrieved, but silently ignored - for some reason Yii will not throw an exception for this.
1 However, this function will still try to find . in the expression and interpret the part after it as the column identifier - do not use . in your expression, and you should be fine.
source share