I am beginner in Yii framework. I was practicing through ebbok" Aggile WebDevelopment with Yii 1.1 ". I got following error in code when I clicked to Create Issue.
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘users.tbl_project_user_assignment(project_id’ in ‘where clause’
First of all you need to carefully select where to post your questions…
as this is related to the book and we have a subforum for it… would be nice if you post all book related questions there… The author of the book replays there…
As for the error… you need to again recheck all your steps with the book… as it says "unknown column"… it means that something is missing… or a column in the database… or some relation… or there is some typing error…
The reason for this error is because the relations in your model file were specified as HAS_MANY, but the actual relation is coming from a MANY_MANY relationship in the database via an association table with a compound primary key.
an example to clarify:
Change this:
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'issues' => array(self::HAS_MANY, 'Issue', 'project_id'),
'users' => array(self::HAS_MANY, 'User', 'tbl_project_user_assignment(project_id,user_id)'),
);
}
To this:
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'issues' => array(self::HAS_MANY, 'Issue', 'project_id'),
'users' => array(self::MANY_MANY, 'User', 'tbl_project_user_assignment(project_id,user_id)'),
);
}