CgridView connecting two Models.

I am learning yii by making a BLOG project.

I have two tables: ‘User’ model contains details related to all users ‘Post’ model contains all the blogs written by users.

User table:

id (auto-increment, primary key),

name,

email,

password,

created_at,

updated_at,

status.

Post table:

id (auto-increment, primary key),

user_id.

I want to display CGridView with three columns so that it displays user id, user name, and count of number of posts created by them.

I am a newbie in yii. I know how to write sql query which would be:

SELECT count(post.id), user.name FROM user join POST on

user.id = post.user_id group by user.id;

how to do it in yii.what to wite in dataprovider,how and where to write all the conditions/filters

(Please help, its urgent)