Relations and lazy loading

Hey guys,

how can I check if relation was in ‘with’ array, after the record is fetched?

For example, if Post belongs to Author

$post = Post::model()->with(...unknown array of relations...)->findByPk(1);

if ($post->author?<img src='' class='bbc_emoticon' alt='???' />?) {

    // related model was attached using eager loading

} else {

    // related model was not attached, so calling $post->author->id will cause extra query


Bad thing here is that $post->author is always true.

Nevermind, I’ve found the answer. ($model->hasRelated does the trick)