Hi Everyone
First time post on here and new to Yii so looking for a bit of help here in understanding the logic
I’ve started going through this book (2nd Edition) and have come across the following
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
public function actionView($id)
{
$issueDataProvider = new CActiveDataProvider(
'Issue',
array(
'criteria' => array(
'condition' => 'project_id=:projectId',
'params' => array(
'projectId' => $this->loadModel($id)->id
),
),
'pagination' => array(
'pageSize' => 1
)
)
);
$this->render('view',array(
'model'=>$this->loadModel($id),
'issueDataProvider' => $issueDataProvider
));
}
I understand all of the code here and what it does, however it struck me as odd that this line
'projectId' => $this->loadModel($id)->id
doesn’t just read
'projectId' => $id
Can anyone explain why this is written this way? Is there any reason it shouldn’t be? I tried the second bit of code to test it and it still works. Any insight into this would be appreciated
Thanks
Jay