summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2015-10-13 13:38:30 +0200
committerAndrey Andreev <narf@devilix.net>2015-10-13 13:38:30 +0200
commit9d02ceafe0aa5ec755f1d8b011cf21f3841191cc (patch)
treec19e38106d6e5979da1061d5a4ac5d83ba88a871
parenta3643a5e92cfe09b48327141d2b52701ab172977 (diff)
[ci skip] Fix #4170
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_driver.php4
-rw-r--r--user_guide_src/source/changelog.rst2
2 files changed, 3 insertions, 3 deletions
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 8d383b274..1df3a4258 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -275,9 +275,7 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*/
public function insert_id()
{
- $query = $this->query('SELECT @@IDENTITY AS insert_id');
- $query = $query->row();
- return $query->insert_id;
+ return $this->query('SELECT SCOPE_IDENTITY() AS insert_id')->row()->insert_id;
}
// --------------------------------------------------------------------
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 5e167a08f..e3dfac879 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -14,6 +14,8 @@ Release Date: Not Released
Bug fixes for 3.0.3
-------------------
+- Fixed a bug (#4170) - :doc:`Database <database/index>` method ``insert_id()`` could return an identity from the wrong scope with the 'sqlsrv' driver.
+
Version 3.0.2
=============