Skip to content

Commit 9d02cea

Browse files
committed
[ci skip] Fix bcit-ci#4170
1 parent a3643a5 commit 9d02cea

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

system/database/drivers/sqlsrv/sqlsrv_driver.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,7 @@ public function affected_rows()
275275
*/
276276
public function insert_id()
277277
{
278-
$query = $this->query('SELECT @@IDENTITY AS insert_id');
279-
$query = $query->row();
280-
return $query->insert_id;
278+
return $this->query('SELECT SCOPE_IDENTITY() AS insert_id')->row()->insert_id;
281279
}
282280

283281
// --------------------------------------------------------------------

user_guide_src/source/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Release Date: Not Released
1414
Bug fixes for 3.0.3
1515
-------------------
1616

17+
- Fixed a bug (#4170) - :doc:`Database <database/index>` method ``insert_id()`` could return an identity from the wrong scope with the 'sqlsrv' driver.
18+
1719
Version 3.0.2
1820
=============
1921

0 commit comments

Comments
 (0)