Yii Framework Forum: Add new condition in Search - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Add new condition in Search Rate Topic: -----

#1 User is offline   neel 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 133
  • Joined: 08-October 09

Posted 16 March 2010 - 07:35 AM

In search, how to add condition

$criteria->addCondition('User_id =' .Yii::app()->user->id),

public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.

$criteria=new CDbCriteria;

return new CActiveDataProvider('Test', array(
'criteria'=>$criteria,
//$criteria->addCondition('User_id =' .Yii::app()->user->id),
));
}
0

#2 User is offline   neel 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 133
  • Joined: 08-October 09

Posted 16 March 2010 - 07:50 AM

problem solved. :rolleyes:
0

#3 User is offline   GSTAR 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,037
  • Joined: 30-October 09
  • Location:UK

Posted 16 March 2010 - 09:04 AM

View PostNeel, on 16 March 2010 - 07:50 AM, said:

problem solved. :rolleyes:


How?
0

#4 User is offline   neel 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 133
  • Joined: 08-October 09

Posted 16 March 2010 - 12:19 PM

View PostGSTAR, on 16 March 2010 - 09:04 AM, said:

How?

public function search()
{
$criteria=new CDbCriteria;
$criteria->compare('name',$this->name,true);
$criteria->addCondition('User_id =' .Yii::app()->user->id);
return new CActiveDataProvider('Test', array(
'criteria'=>$criteria,
));
}
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users