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='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' 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.