calling fields from other table using key

Can anyone helps me to clear this…

i need to display the username from user table in question view file… using userId which is the key column for two tables…

My table structure is this…

table name user

columns=> userId,userName, userType

key=> userId(primary)

table name question

columns=> userId(foreign key references users), questionId(A_I),question

key=>questionId

when user posts new question his userId will be stored in question table…

Now i need to display the username in question view file…

Since i am new to Yii i am not able to do this i don’t know anything about this… So pls help me…

You need to learn about configuring and using relations. If you used yiic or Gii to generate your models and your foreign key constraints were correctly set up, the relations may already exist in the model classes.

All U need to do is to setup relation:

http://www.yiiframework.com/doc/guide/1.1/en/database.arr#performing-relational-query

This very usefully for :) Thank you

Thank you friends… It helps me to learn Yii with interest…