Chapter 6 SQL problem unknow column projectId in where claus

public function actionView($id)


	$issueDataProvider=new CActiveDataProvider('Issue', array(















I get this error:


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_project t WHERE project_id=projectId

Why am I getting this error, its code from the book? Anyone has a explanation for this?

i haven’t read the book , seems every thing is ok , strange thing ::)

just replace $this->loadModel($id)->id to an integer value to see if the error still occurs !

its same, only way it will work is if I do this:


how does Yii actually translate



to SQL "…where project_id=1…"

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:


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.


Can you include the create statement used (or the total table description) of tbl_project?

The message clearly states that column projectId is missing, so it looks something is wrong in definition.