欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

Yii 添加自己的搜索条件

程序员文章站 2022-06-02 12:09:42
...
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 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教程有兴趣的朋友有所帮助。