Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14348

CI 3.1.0 - Trouble with Identity-fields and sqlsrv

$
0
0
Hi there,

I am using CodeIgniter for a few weeks now and I am impressed.

But after migrating one project from a LAMP to a Windows Apache MSSQL2012 PHP7.0 machine my troubles started.

As mssql isn't available within PHP 7 I took sqlsrv and installed it, tried to connect worked from first attempt. So far this could be a success-story, but it is not. On updates I get the message:

Quote:A Database Error Occurred
Error Number: 42000/8102
[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Die id-Identitätsspalte kann nicht aktualisiert werden."
The last part basically means "The ID-identy column may not be updated."
The generated update-query looks like this:
Code:
UPDATE "dbo"."table" SET "id" = 1, "someStuff" = stuffValue WHERE "id" = 1

My models use statements like:
Code:
$data = array (
  'someStuff' => (int) $stuff
);
$this->db->update('table',$data,"id = ".$itemID);
I don't know why and when CI comes to the conclusion it would be great to insert the "id"-field into the SET-part of my update query, but it is not great - I already thought it would be a great idea for the id field to be identity(1,1) and mssql doesn't want queries to mess around with these.
Is there an easy and obvious solution I missed or am I doomed to write my own database-connection?

Viewing all articles
Browse latest Browse all 14348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>