Getting related models in templates?
I would move that logic out of your model class and into a service method.

Your model could still have a thin wrapper for it:

public function getVideos()
{
    return craft()-&gt;myPluginVideoService-&gt;getVideosByChannelId($this-&gt;id);
}


Then your plugin's video service would have:

public function getVideosByChannelId($channelId)
{
    // Can memoize by channelId if this will be called frequently

    $result = craft()-&gt;db-&gt;createCommand()
        -&gt;select('*')
        -&gt;from('myVideoTable')
        -&gt;where('channelId = :channelId', array(':channelId' =&gt; $channelId))
        -&gt;queryAll();

    if ($result)
    {
        return MyPlugin_VideoModel::populateModels($result);
    }
}


The benefits are:


Less cruft in your models, which should (as much as possible) be used as data transport objects
You're not leaking records out of your service layer (like your original model was doing)
You're building a consistent API at your service layer that any other classes (other models, other template variables, other services, other plugins, etc.) can go through.


But essentially you're correct. You'll need to write methods to expose the relationships you're looking for to the templates.


  what is the reason you use the direct database API, in stead of the Record::model()-&gt;findAllByPk($pksArray) method?


Habit. Active records, while convenient for simple use-cases, have performance overhead associated with them, so usually I just default to DbCommand.