CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1
Your error looks like your Yii::app()->user->id contains no value which causes a broken condition clause.
In fact, if the user is not authenticated, Yii::app()->user->id defaults to NULL.
Either, check if your user is NULL before inserting it into your condition, or use (int)Yii::app()->user->id to guarantee an integer value (NULL will be 0).