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 get this error:
CDbException
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘projectId’ in ‘where clause’. The SQL statement executed was:
SELECT COUNT(*) FROM tbl_projectt WHERE project_id=projectId
Why am I getting this error, its code from the book? Anyone has a explanation for this?
If you look at my error, translation of projectId to the number value has not occured. Wonder where things went wrong there?
How does Yii do this thing, is it done behind the curtains after I assigned the value using ‘params’. Why should we use ‘params’ to assign values and not directly like this:
'condition'=>'project_id='.$id
isn’t that more natural or are there benefits to do it the way book example shows?
Would be thankfull for some explanation here and how others do it.