Reputation: 360
I get this error when I didn't do anything for a while, I'm not sure if this is a Session problem or not.
The error message is:
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 '=='1')' at line 1. The SQL statement executed was: SELECT * FROM
games_developers_app
t
WHERE (status LIKE :ycp0) AND (developer_id==:ycp1)
The code is:
public function actionSortReject(){
$util = new Utility();
$util->detectMobileBrowser();
$util->checkWebSiteLanguageInCookies();
$this->layout = "masterLayout";
$count = '0';
$id = Yii::app()->user->getState('id');
$searchsort = "REJ";
$sort = new CDbCriteria();
$sort->addSearchCondition('status', $searchsort);
$sort->addCondition('developer_id='.$id);
$models = GamesDevelopersApp::model()->findAll($sort,array('developer_id'=>$id));
$this->render('/register/applist',array('models'=>$models,'count'=>$count));
}
It seems that everything worked fine, if I missed something in my code please tell me. Thanks =)
Upvotes: 1
Views: 1621
Reputation: 14860
The problem is a combination how you have called compare
and added additional parameters to findAll
.
Your compare
should be as follows:
$sort->compare('developer_id', $id);
And your findAll
should be:
$models = GamesDevelopersApp::model()->findAll($sort);
You could also use addCondition
as follows:
$sort->addCondition('developer_id=:developer_id');
$sort->params[':developer_id'] = $id;
Upvotes: 1