Page 1 of 1
CDbCommand error - Unknown column
#1
Posted 09 December 2010 - 09:10 AM
I am learning Yii framework via the "Agile Web Application Development .. " book and am getting this error during testing:
1) ProjectTest::testGetUserOptions
CDbException: CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users_users.user_id)' in 'on clause'
The column name is "users_users.user_id" and I think it should be just "users.user_id".
The error was generated when executing this command:
public function getUserOptions()
{
$usersArray = CHtml::listData($this->users, 'id', 'username');
return $usersArray;
}
I have no idea how to begin troubleshooting this.
Can anyone help me?
1) ProjectTest::testGetUserOptions
CDbException: CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users_users.user_id)' in 'on clause'
The column name is "users_users.user_id" and I think it should be just "users.user_id".
The error was generated when executing this command:
public function getUserOptions()
{
$usersArray = CHtml::listData($this->users, 'id', 'username');
return $usersArray;
}
I have no idea how to begin troubleshooting this.
Can anyone help me?
#2
Posted 09 December 2010 - 09:17 AM
paullorentzen, on 09 December 2010 - 09:10 AM, said:
I am learning Yii framework via the "Agile Web Application Development .. " book and am getting this error during testing:
1) ProjectTest::testGetUserOptions
CDbException: CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users_users.user_id)' in 'on clause'
The column name is "users_users.user_id" and I think it should be just "users.user_id".
The error was generated when executing this command:
public function getUserOptions()
{
$usersArray = CHtml::listData($this->users, 'id', 'username');
return $usersArray;
}
I have no idea how to begin troubleshooting this.
Can anyone help me?
1) ProjectTest::testGetUserOptions
CDbException: CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users_users.user_id)' in 'on clause'
The column name is "users_users.user_id" and I think it should be just "users.user_id".
The error was generated when executing this command:
public function getUserOptions()
{
$usersArray = CHtml::listData($this->users, 'id', 'username');
return $usersArray;
}
I have no idea how to begin troubleshooting this.
Can anyone help me?
if u want to list out from ur model User follow this code hope it will help u
return(CHtml::listData(User::model()->findAll(), 'id', 'username'));
#3
Posted 09 December 2010 - 09:47 AM
paullorentzen, on 09 December 2010 - 09:10 AM, said:
I am learning Yii framework via the "Agile Web Application Development .. " book and am getting this error during testing:
1) ProjectTest::testGetUserOptions
CDbException: CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users_users.user_id)' in 'on clause'
The column name is "users_users.user_id" and I think it should be just "users.user_id".
The error was generated when executing this command:
public function getUserOptions()
{
$usersArray = CHtml::listData($this->users, 'id', 'username');
return $usersArray;
}
I have no idea how to begin troubleshooting this.
Can anyone help me?
1) ProjectTest::testGetUserOptions
CDbException: CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users_users.user_id)' in 'on clause'
The column name is "users_users.user_id" and I think it should be just "users.user_id".
The error was generated when executing this command:
public function getUserOptions()
{
$usersArray = CHtml::listData($this->users, 'id', 'username');
return $usersArray;
}
I have no idea how to begin troubleshooting this.
Can anyone help me?
Could you share what your relations() method looks like in your Project model class?
#4
Posted 09 December 2010 - 09:51 AM
Thirumalai, on 09 December 2010 - 09:17 AM, said:
if u want to list out from ur model User follow this code hope it will help u
return(CHtml::listData(User::model()->findAll(), 'id', 'username'));
Thanks for the reply.
I'm not sure where to use your line of code.
My error is generated when running the unit test below and is triggered by the bold line
public function testGetUserOptions()
{
$project = $this->projects('project1');
$options = $project->userOptions;
// $this->assertTrue(is_array($options));
// $this->assertTrue(count($options) > 0);
}
I just created the get method in the Project AR that looks like this:
public function getUserOptions()
{
$usersArray = CHtml::listData($this->users, 'id', 'username');
return $usersArray;
}
If I manually return an array from the Project AR (using this code), everything works fine:
public function getUserOptions()
{
return array(
'test1' => 'test1',
'test2' => 'test2',
);
}
#5
Posted 09 December 2010 - 10:31 AM
jefftulsa, on 09 December 2010 - 09:47 AM, said:
Could you share what your relations() method looks like in your Project model class?
Here are my Project AR relations
'issues' => array(self::HAS_MANY, 'Issues', 'project_id'),
'users' => array(self::MANY_MANY, 'User', 'tbl_project_user_assignment(project_id, user_id))'),
#9
Posted 09 December 2010 - 07:33 PM
jrewing is right! Check EVERYTHING!
If you look at the users element relations() method of the model class, there is an extra left paren. toward the end.
Thanks for everyones help; I'll look at little close at the simple things next time.
If you look at the users element relations() method of the model class, there is an extra left paren. toward the end.
Thanks for everyones help; I'll look at little close at the simple things next time.
Share this topic:
Page 1 of 1

Help

This topic is locked










