how to search in text saved as array on database

Hi … i used select2Group-Widget to select multiple, and saved with tokenSeparators ‘comma’.

please write code to get array string from database then:

  • search between comma by foreach and if exist do something, else do something-else;

in _form:




<?php

        echo $form->select2Group($model, 'department',

        array(

            'wrapperHtmlOptions' => array(),

            'widgetOptions' => array('asDropDownList' => FALSE,

                'htmlOptions' => array('class' => 'input-lg'),

            'options' => array(

            'tags' => Yii::app()->params['community'],

            'tokenSeparators' => array(',', ' ')))));

    ?>



in view

[size="3"]i need your code in this page [/size]




$res = Report::model()->findAllByAttributes(array('department'=>'HR'));



NOTE: "HR" one element of array, and "department" is a column and Select2 widget saving in it like that:(AC,HR,SC,TS)

Hi,

… what was the solution?

Since you ask for code when you need help - it would be nice and fair if you also share your code & solution.

Regards

not full done :( … some code include error … i try