public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria=new CDbCriteria; $criteria->compare('usertest_id',$this->usertest_id,true); $criteria->compare('usertest_project',$this->usertest_project,true); $criteria->compare('usertest_imei',$this->usertest_imei,true); //$criteria->compare('usertest_sw',$this->usertest_sw,true); $whereSql = "usertest_sw like '"; //Y2A5HA80BR20 Y2A5GD80BR10 Y2A5*80BR20 usertest_sw like '%Y2A5%80BR20%' $keyword = $this->usertest_sw; $keyarr=explode('*',$keyword); for($index = 0; $index < count($keyarr); $index++) { $whereSql .= "%$keyarr[$index]"; } $whereSql .= "%'"; $criteria->addCondition($whereSql); $criteria->compare('usertest_package',$this->usertest_package,true); $criteria->compare('usertest_type',$this->usertest_type,true); $criteria->compare('usertest_logtime',$this->usertest_logtime,true); $criteria->compare('usertest_cu',$this->usertest_cu,true); $criteria->compare('usertest_localtime',$this->usertest_localtime,true); $criteria->compare('usertest_logpath',$this->usertest_logpath,true); $criteria->compare('usertest_logkeyinfo',$this->usertest_logkeyinfo,true); $criteria->compare('usertest_bugid',$this->usertest_bugid,true); $criteria->compare('usertest_bugstatus',$this->usertest_bugstatus,true); $criteria->compare('usertest_comments',$this->usertest_comments,true); $criteria->compare('usertest_userinfo',$this->usertest_userinfo,true); $criteria->compare('usertest_repeatcount',$this->usertest_repeatcount,true); return new CActiveDataProvider($this, array( 'criteria'=>$criteria, 'sort'=>array( 'defaultOrder'=>'usertest_logtime desc', ), )); }
위 내용을 포함하여 Yii에서 자신만의 검색 조건을 추가하는 방법을 소개하고 있으니 PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되었으면 좋겠습니다.