Yii Cdbcriteria Find A Specific Charater In String

i’m not good with sql, i’m making a CListView for all records with a selected id in column to be displayed on the page… just for practice, i wanted to add a dropdown that will select another kind of sort (id DESC is already there).

i have a table with columns: id, Name, Project_id, User_id, Assigned, etc…

for now this is my code:




public function actionView($id)

    {

        $model = $this->loadModel($id);


        $criteria = new CDbCriteria(array(

            'order'=>'id desc',

            'condition'=>'Project_id='.$id

        ));


        $dataProvider = new CActiveDataProvider('Task', array(

            'criteria'=>$criteria

        ));


        $this->layout = 'column2';


        $this->render('view', array('model'=>$model, 'dataProvider'=>$dataProvider));

    }



i’m selecting all records that has the requested project_id, so what i’m trying to do, which i have no clue how to do, is to add another criteria selection on the column “Assigned” the problem is, some of this records has more than 1 single assigned and its being saved as “1,2,5,6”. so if i add another selection with assigned 1, it will just show me thoses records that have in assigned “1” and not thoses that have “1,3,5,6”… i was thinking on make a search on string but i dont know how it works on sql (Because i dont know SQL that much).

Update: ive been told to use find_in_set()… but i tried it like this:


$criteria = new CDbCriteria(array(

    'order'=>'id desc',

    'condition'=>'Project_id='.$id.' AND find_in_set(1, Assigned)'

));

but it gives me this error: CDbCommand failed to execute the SQL statement: CDbCommand failed to prepare the SQL statement: SQLSTATE[HY000]: General error: 1 no such function: find_in_set. The SQL statement executed was: SELECT COUNT(*) FROM ‘task’ ‘t’ WHERE Project_id=1 AND find_in_set(1, Assigned)

Take a look a this discussion