yiisoft/yii — pull request #1382 by NickRenold (2012-09-12 03:21:29+00:00)
Title: Adding support for relation definition as objects in array, instead of config array

I think this type of config for the models is much more self-documenting, with the added addition of supporting autocomplete. I believe it is more beginner-friendly.

Old way:
```php
public function relations()
{
return array(
'posts'=>array(self::HAS_MANY, 'Post', 'author_id'),
'profile'=>array(self::HAS_ONE, 'Profile', 'owner_id'),
);
}
```

Newly enabled way:
```php
public function relations()
{
return array(
new CHasManyRelation('posts', 'Post', 'author_id'),
new CHasOneRelation('profile', 'Profile', 'owner_id'),
);
}
```

Especially it has a better way of configuring advanced relations:
```php
public function relations()
{
$posts = new CHasManyRelation('posts','Post','author_id');
$posts->condition = 'posts.deleted=0';

$profile = new CHasOneRelation('profile', 'Profile', 'owner_id'),

return array(
$posts,
$profile,
);
}
```