Accessing data in a join table with the related models

Comparing #5 with #6

Revision #6 was created by fsb fsb on Mar 18, 2012, 6:55:01 PM.

formatting

Content

[...]
```php
$viewer = Viewer::model()->findByPk($id);
foreach ($viewer->movies as $movie)
echo $viewer . ' watched ' . $movie->title;
```
[This will perform poorly because it lazily loads `Movie`s one as a time in the loop. I can pep it up
with `with()`thus: `Viewer::model()->with('movies')->findByPk($id).`]

### The problem

How can I add the `liked` property to that `echo` in the loop? For example, is there a way to write relations and/or getters so I can write?:
[...]