yiisoft/yii — pull request #1459 by creocoder (2012-09-23 10:25:05+00:00)
Title: [DEMO] CModelCollection and CActiverecordCollection

This give new cool features.

Before collections:

```
public function actionUpdate($id)
{
...
if(isset($_POST['Country'],$_POST['CountryTranslation']))
{
$model->attributes=$_POST['Country'];
$valid=$model->validate();

foreach($translations as $language_id=>$translation)
{
if(isset($_POST['CountryTranslation'][$language_id]))
$translation->attributes=$_POST['CountryTranslation'][$language_id];

$valid=$translation->validate() && $valid;
}

if($valid)
{
$transaction=Yii::app()->db->beginTransaction();

try
{
$model->save(false);

foreach($translations as $language_id=>$translation)
{
$translation->country_id=$model->id;
$translation->language_id=$language_id;
$translation->save(false);
}

$transaction->commit();
$this->redirect(array('index'));
}
catch(Exception $e)
{
$transaction->rollback();
throw $e;
}
}
}
...
}
```

After:

```
public function actionUpdate($id)
{
...
if(isset($_POST['Country'],$_POST['CountryTranslation']))
{
$model->attributes=$_POST['Country'];
$valid=$model->validate();
$model->translations->attributes=$_POST['CountryTranslation'];
$valid=$model->translations->validate() && $valid;

if($valid)
{
$transaction=Yii::app()->db->beginTransaction();

try
{
$model->save(false);
$model->translations->save(false);
$transaction->commit();
$this->redirect(array('index'));
}
catch(Exception $e)
{
$transaction->rollback();
throw $e;
}
}
}
...
}
```

What do you think about it feature? Implementation full BC (i think), at least all my old applications work fine.