Relations in ORM

Hi guys! I am totally new to YII, so my question might be really silly.

I need to know when and where CActiveRecord->getMetaData()->relations is filled.

For example, when I write in template something like




print_r($post->comments);



where the comments property is set?

Comments is a relation that is in the Post model file.

See the relational active record section of the documentation.

if you are using lazy loading, the default, it is loaded when it is read

if you are using eager loading (using the with() function) then it is loaded when the post is loaded