I wish to do a search function for my yii project. I found out in yii that is a function called addSearchCondition(), then I tried to do the search function.
public function actionSearchApp(){
$searchapp = $_POST['searchapp'];
$id = Yii::app()->user->getState('id');
$models = GamesDevelopersApp::model()->findAll('developer_id='.$id);
array('models'=>$models);
foreach($models as $model){
$gametitle = CHtml::encode($model->gametitle);
}
$search = new CDbCriteria();
$search->addSearchCondition($gametitle.'LIKE:'.$searchapp);
$result = GamesDevelopersApp::model()->findAll($search);
print_r($result);
}
Error Message: Missing argument 2 for CDbCriteria::addSearchCondition()
Any Suggestion for doing SQL Like in Yii ? or any good example for doing search function in yii
Hi thanks for your reply ⌠I tried ⌠still not work âŚ
Error Message : CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column âGGâ in âwhere clauseâ. The SQL statement executed was: SELECT * FROM games_developers_appt WHERE GG LIKE :ycp0
$gametitle should represent DB column name from table that U are searching from, or from related tables (but that it has to be in format relationName.column_name).
Can U tell me what table are U searching for and from wnat table $gametitle is ?
Im using GamesDevelopersApp() model to find the gametitle where the developer_id=âcorrect idâ, then from all the gametitle LIKE the âI have entered in search fieldâ to find the result I need