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', ), )); }
The above introduces how to add your own search conditions in Yii, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.