What and how many SQL statements are called

I’ve got 3 tables in my DB:

Product

ID

Name

Tag

ID

Tag

Product_Tags

ProductID

TagID

I’ve created a Product and a Tag AR Class with the Many_Many relationships.

If I use this code:


$product=Product::model()->findByPk(1);

echo $product->tags[0]->Tag; 

What queries are called by YII? And… At what time are the queries called?

What I think:

After line 1 the query for getting the Product and the query for getting all Tags are called. Is this right?

By The Way: Is it possible to see all queries during a request in YII?

The best way is to use your log to ensure assumptions: http://www.yiiframework.com/wiki/58/sql-logging-and-profiling-in-firebug-yii-1-1/

Cheers