0

My normal array is like this

**Array ( [0] => Array ( [name] => companyadmin [type] => 2 [description] => companyadmin [bizrule] => companyadmin [data] => N; [created_by] => 15 [trade_company_id] => 0 )

) **

and i want to convert it to yii object array. hows this convertible?

2
  • What is a yii object array? Commented Dec 11, 2014 at 7:00
  • sorry i am new in yii.i mean model array... Commented Dec 11, 2014 at 7:06

1 Answer 1

1

If you want create model from array

CActiveRecord::model('ClassName')->populateRecord($data).

or

$model = new ClassModel;
$model->attributes = $data;
Sign up to request clarification or add additional context in comments.

4 Comments

Thanx @Konstantin. but in rights module i cant use this.
Try to describe in detail what you have and what you want to do
Address::model()->findAll() gives me array.i used $sql = "SELECT * FROM authitem WHERE created_by=".Yii::app()->user->id; $dbCommand = Yii::app()->db->createCommand($sql); $data = $dbCommand->queryAll(); but array format is different. so i want same array format like other model.
Method CActiveRecord.findAll() use populateRecords too: retrun $this->populateRecords($command->queryAll(), true, $criteria->index)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.