Update Query In Yii Framework


I am newbie here, I need to update a row in my table

below is the code Im using


$sql=‘update tablename set userid =:userid where ID=:ID’;





But I am getting below error

CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘userId’ in ‘field list’.

But there is userId in the DB not sure if my coding is wrong

Can you post your exact code and the schema for the relevant table?

Also, use code tags when posting code; they can be inserted using the "<>" icon in the editor window.

Table name - usertable

field names - ID(int autoincrement), userid (int), username (varchar(100)

Below is the code Im using


$sql='update usertable set userid =:userid where ID=:ID';






This error can show up when something has not been binded properly, so the generated sql looks like this:

UPDATE usertable SET userid = userId where ID = ‘your ID’;

The funny thing is the only camelcased "userId" is the array key.

Ok, first of all, try to use bindValue instead of bindParam and see if something changes.