Yii Framework Forum: Multiple Condition In Active Record - Yii Framework Forum

Jump to content

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

Multiple Condition In Active Record Rate Topic: -----

#1 User is offline   sudhakarraju 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 18-December 12

Posted 18 December 2012 - 08:21 AM

Hello
First i asked sorry for my english.
I have created multiple search in my form but i am not able get correct result
my module
public function getAll($id,$name,$country)
{
$criteria=new CDbCriteria;
$criteria->with=array('Country','State');
$criteria->together=true;
$criteria->compare('t.user_id',$id,true,'OR');
$criteria->compare('t.user_nmae',$name,true,'OR');
$criteria->compare('country.id',$country,true,'OR');
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}

my controler

public function actionAdminaction(){
$model=new TblUser;

if(isset($_POST['userid'])){
$id=$_POST['userid'];

}
if(isset($_POST['username'])){
$name=$_POST['username'];
}
if(isset($_POST['country'])){
$country=$_POST['country'];

}


$dataProvider=$model->getAll($id,$name,$country);
var_dump($dataProvider);
}
whenever print my data stored array i got below like this
object(CActiveDataProvider)[42]
public 'modelClass' => string 'TblUser' (length=7)
public 'model' =>
object(TblUser)[23]
private '_md' (CActiveRecord) =>
object(CActiveRecordMetaData)[25]
public 'tableSchema' =>
object(CMysqlTableSchema)[29]
...
public 'columns' =>
array
...
public 'relations' =>
array
...
public 'attributeDefaults' =>
array
...
private '_model' =>
object(TblUser)[24]
...
private '_new' (CActiveRecord) => boolean true
private '_attributes' (CActiveRecord) =>
array
empty
private '_related' (CActiveRecord) =>
array
empty
private '_c' (CActiveRecord) => null
private '_pk' (CActiveRecord) => null
private '_alias' (CActiveRecord) => string 't' (length=1)
private '_errors' (CModel) =>
array
empty
private '_validators' (CModel) => null
private '_scenario' (CModel) => string 'insert' (length=6)
private '_e' (CComponent) => null
private '_m' (CComponent) => null
public 'keyAttribute' => null
private '_criteria' =>
object(CDbCriteria)[41]
public 'select' => string '*' (length=1)
public 'distinct' => boolean false
public 'condition' => string '((t.user_id LIKE :ycp0) OR (t.user_nmae LIKE :ycp1)) OR (country.id LIKE :ycp2)' (length=79)
public 'params' =>
array
':ycp0' => string '%1%' (length=3)
':ycp1' => string '%sudhakar%' (length=10)
':ycp2' => string '%1%' (length=3)
public 'limit' => int -1
public 'offset' => int -1
public 'order' => string '' (length=0)
public 'group' => string '' (length=0)
public 'join' => string '' (length=0)
public 'having' => string '' (length=0)
public 'with' =>
array
0 => string 'Country' (length=7)
1 => string 'State' (length=5)
public 'alias' => null
public 'together' => boolean true
public 'index' => null
public 'scopes' => null
private '_e' (CComponent) => null
private '_m' (CComponent) => null
private '_id' (CDataProvider) => string 'TblUser' (length=7)
private '_data' (CDataProvider) => null
private '_keys' (CDataProvider) => null
private '_totalItemCount' (CDataProvider) => null
private '_sort' (CDataProvider) => null
private '_pagination' (CDataProvider) => null
private '_e' (CComponent) => null
private '_m' (CComponent) => null
please give me right solutions
0

#2 User is offline   ragua 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 135
  • Joined: 23-January 12
  • Location:Paris - France

Posted 18 December 2012 - 10:30 AM

Hi Sudhakarraju,
can you tell us more about your problem, have you got wrong answer or a database error for instance?
You should also use the insert code snipset (<>), it's more readable with it.
0

#3 User is offline   Sergey_S 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 01-October 12

Posted 18 December 2012 - 11:37 AM

If I correctly understood your question, you want to get data as an array, not as an object (using CActiveDataProvider)?
0

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