I've read Active Record section several times under The Definitive guide to Yii and can't fully understand the with() method of CActiveRecord class. In the guide, there is a something like this:
It explains as "the code will bring back posts together with their authors and categories".
However, these is no categories like property in the Post class. What does "the code will bring back posts together with categories" mean?
How can I access the categories stuff that brought back by the code above through $post?
If I want to access the category id, I still have to do $posts->category->id, then why I need to do it with with() method?
You make it so very clear by your examples. It is not so clearly explained in the documentation.
I have a question: when using with findAll, in terms of performance and rapidity of execution, does eager loading always produce faster results than lazy loading? Or does it also depend on the number of elements in the array returned?