Loadmodel for two or more related tables

hi! i have a problem in my actionUpdate and loadmodel function when i update a form with relations. There is no problem with my actioncreate. The loadmodel should point to all related tables.

public function actionUpdate($id)

{


	$model = $this->loadModel($id);


	$account = $this->loadModel($id);


	$student = $this->loadModel($id);


	$faculty = $this->loadModel($id);


	// Uncomment the following line if AJAX validation is needed


	// $this->performAjaxValidation($model);





	if(isset($_POST['Patron']))


	{


		$model->attributes=$_POST['Patron'];


	


		if($model->save())


			$this->redirect(array('view','id'=>$model->Patron_ID));


		


	}





	$this->render('update',array(


		'model'=>$model,


		'account'=>$account,


		'student'=>$student,


		'faculty'=>$faculty,


	));


}

public function loadModel($id)

{


	$model=Patron::model()->with('PatronAccount')-with('Student')->findByPk($id);


	


	if($model===null)


		throw new CHttpException(404,'The requested page does not exist.');


	return $model;


}

sorry i’m just new to yii.

Please see the usage of with() - http://www.yiiframework.com/doc/api/1.1/CActiveRecord#with-detail


$model=Patron::model()->with('PatronAccount','Student')->findByPk($id);

then once you assign


$model = $this->loadModel($id);

you should access student and account information via $model->PatronAccount->username;

The above usage is just an example you should use the attributes you’ve declared in each model.