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:

$data = $this->getUser($id);
$model = new Users;
$model = $model->populateRecord($data, FALSE);

instead of (last line):

$model->populateRecord($data, FALSE);

because populateRecord creates new model instead of modifying existing one!

Leave a Reply