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'
E:\xampp\htdocs\trackstar\protected\models\Project.php(113)
00101:
00102: return new CActiveDataProvider(get_class($this), array(
00103: 'criteria'=>$criteria,
00104: ));
00105: }
00106:
00107: /**
00108: * populate users
00109: */
00110: public function getUserOption()
00111: {
00112: $userArray = array();
00113: $userArray = CHtml::listData($this->users,'id','username');
00114: return $userArray;
00115:
00116: /*return array(
00117: self::USER_1=>'User1',
00118: self::USER_2=>'User2',
00119: );*/
00120: }
00121: }
Can anybody help me ?
Page 1 of 1
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]:
#2
Posted 30 November 2010 - 12:22 PM
Can you provide the details of what your table looks like? Was your table created using the following sql?:
CREATE TABLE `tbl_project_user_assignment` ( `project_id` Int(11) NOT NULL, `user_id` Int(11) NOT NULL, `create_time` DATETIME, `create_user_id` INTEGER, `update_time` DATETIME, `update_user_id` INTEGER, PRIMARY KEY (`project_id`,`user_id`) ) ENGINE = InnoDB ;
#3
Posted 01 December 2010 - 10:44 PM
I had this error as well. It turns out I was doing:
'users' => array(self::HAS_MANY, 'User', 'tbl_project_user_assignment(project_id, user_id)'),
...instead of:
'users' => array(self::MANY_MANY, 'User', 'tbl_project_user_assignment(project_id, user_id)'),
in the Project model's relations array.
'users' => array(self::HAS_MANY, 'User', 'tbl_project_user_assignment(project_id, user_id)'),
...instead of:
'users' => array(self::MANY_MANY, 'User', 'tbl_project_user_assignment(project_id, user_id)'),
in the Project model's relations array.
#4
Posted 01 December 2010 - 10:58 PM
No I am using MySQL.
jefftulsa, on 30 November 2010 - 12:22 PM, said:
Can you provide the details of what your table looks like? Was your table created using the following sql?:
CREATE TABLE `tbl_project_user_assignment` ( `project_id` Int(11) NOT NULL, `user_id` Int(11) NOT NULL, `create_time` DATETIME, `create_user_id` INTEGER, `update_time` DATETIME, `update_user_id` INTEGER, PRIMARY KEY (`project_id`,`user_id`) ) ENGINE = InnoDB ;
#5
Posted 01 December 2010 - 11:03 PM
ddumitrescu, on 01 December 2010 - 10:44 PM, said:
I had this error as well. It turns out I was doing:
'users' => array(self::HAS_MANY, 'User', 'tbl_project_user_assignment(project_id, user_id)'),
...instead of:
'users' => array(self::MANY_MANY, 'User', 'tbl_project_user_assignment(project_id, user_id)'),
in the Project model's relations array.
'users' => array(self::HAS_MANY, 'User', 'tbl_project_user_assignment(project_id, user_id)'),
...instead of:
'users' => array(self::MANY_MANY, 'User', 'tbl_project_user_assignment(project_id, user_id)'),
in the Project model's relations array.
I am using the following relations:
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(
'issue'=>array(self::HAS_MANY, 'Issue','project_id'),
'users'=>array(self::HAS_MANY,'user','tbl_project_user_assignment(project_id,user_id)'),
);
}
#6
Posted 01 December 2010 - 11:06 PM
Yeah, that's how I had it too when I got the error. Try changing the 'users' one to MANY_MANY. It fixed it for me.
#7
Posted 02 December 2010 - 01:09 AM
ddumitrescu, on 01 December 2010 - 11:06 PM, said:
Yeah, that's how I had it too when I got the error. Try changing the 'users' one to MANY_MANY. It fixed it for me.
Yes you are right. There should be MANY_MANY relationship, as there is third table provided with FK so it must be MANY_MANY. Later I realize.
Thanks for you support too.
Share this topic:
Page 1 of 1

Help













