Strange Behaviour In Yii Web Service/mssql

I have a Yii web service which has been working fine until now.

All of a sudden I am getting an error message when trying to update an existing record, saying:

I’ve looked in the MSSQL db and the table which I am using has a primary key set for it. However, after reading some posts I noticed one solution was to include the following method in the model:

After including this piece of code, the update creates a new row with id = 1, although it is not this id that it should update. Running a second update updates the correct row with id 815.

I have also managed to remove this error by specify id in the findByAttributes query, but I should not have to specify the id as I don’t know it before it is being inserted/updated. This does not work:

But this works:

Is there something wrong in the MSSQL table settings, or in the Yii code somehow?

Are there any active users in the Yii forum??

This message generally comes when primary key is not defined for the table. Check this link

The primary key is defined for the table. As you can read in my post, I have also tried to add the following rows to the model class, and then it works to update. However, it will then only update row with id 1 without taking other criteria into consideration.