Populate record

You can use CActiveRecord::populateRecord method in Yii to create new record basing on existing one. And, as this descriptions means, you must use it like that:

[code language=”php”]
$data = $this->getUser($id);
$model = new Users;
$model = $model->populateRecord($data, FALSE);
[/code]

instead of (last line):

[code language=”php”]
$model->populateRecord($data, FALSE);
[/code]

because populateRecord creates new model instead of modifying existing one!

Leave a Reply