Primary Key Value Not Set After Save For Mssql 2008 R2 After Save.

So I’m not sure if this is a bug or not so reading the post I found I should post this here. This previous article here seems to be the same thing but it was back on version 1.1.8. I’m running 1.1.13.

I have other database objects in the same instance of Yii which point to mysql and work fine. This one points to MSSQL 2008 R2. I’m only using gii generated CRUD. The create works fine BUT after the save happens the primary key in this case $model->id does not get updated with the newly created id. This is an identity column and as I said the save does happen properly the data does get saved to the table and you can go back and see it even through the app if you search and click view. It’s just the redirect in the actual save doesn’t work because the $model->id doesn’t get updated. I even mailed a copy of the object to myself after the save and inside the gii generated if ($model->save()) and the model clearly doesn’t have the $model->id updated. I’ve also checked the log and yii doesn’t appear to have any error that is not getting passed through.

What else do I need to post here or should I check locally to try and determine what my issue is? I’m kind of stumped because everything has always just worked in mysql.

It worried me that I saw so many posts of this working for other people but not me. So I looked a little harder and I think I may have the issue sorted but do not know how to fix it. In all the examples I see nobody is using a schema other than the default of dbo. I however am. I did notice that gii couldn’t see the schema but seemed to work fine if I typed in the table name with the schema an example would be ‘LocumData.employee_type’. It read the tables fine created the model and crud no issues. Like I said the create creates but fails to update the id and the update and deletes work with no issue.

I went back to the same database made just a table with a PK and one column but in the default schema "dbo.yii_test" of course gii see this one without having to type it in I followed the same steps again and this time everything works as expected. Could this use of schema be my issue and if so any insight as to how I could "adapt" the framework to use it. Our DBA likes to use few databases for smaller projects and likes to use schema to assign permissions more effectively.

Thanks!