Joining data with Active Record

Hi,

Imagine the flowing schema:

Table - columns


users - userid, name, usergroup

usergroups - usergroupid, name, category

categories - categoryid, name

All tables connected with foreign key: usergroup <-> usergroupid | category <-> categoryid.

How can I get the category name filtering by an username?

Thanks

Got it:




$record = Users::model()->with(

				array(

					'usergroup.category'

				)

			)->findByAttributes(

				array(

					'name' => $this->name

				)

			);