How To Access Data In From Database?

i hav a table "student"(id,rollno,name,class,division,subject1,subject2,subject3,subject4,subject5).

Here in this fields i enter the respective datas and in the (subject1,subject2…) i enter the respective subject from the dropdownlist with the help of another table "mastersubject"

And i do also hav another table "result"(id,rollno,subject1,subject2,subject3,subject4,subject5), here in this subject fields i enter the respective marks. I have made the "rollno" field foriegn key.

Now i hav a form in the yii in which ,when i select the "rollno" i need to get the marks of respective students.

so i need to write the

public function actionResult()


	 //renders the view file 'protected/views/site/index.php'

	//using the default layout 'protected/views/layouts/main.php'

	$model=new student;





		$roll = $model->rollno;

		$class = $model->class;

		$division= $model->division;


		$result =result::model()->findAllByAttributes(array('rollno'=>$roll)   

       foreach( $result as $dev)


			echo $dev['rollno'];

			echo "subject1:".$dev['subject1'];









can anyone help with this,i really new to yii. so please do help me. Thanks in advance.