Fixed fetching last inserted ID from a SQL Server connection

parent b1953ea1
...@@ -136,11 +136,11 @@ class SQLSrvConnection implements Connection, ServerInfoAwareConnection ...@@ -136,11 +136,11 @@ class SQLSrvConnection implements Connection, ServerInfoAwareConnection
if ($name !== null) { if ($name !== null) {
$stmt = $this->prepare('SELECT CONVERT(VARCHAR(MAX), current_value) FROM sys.sequences WHERE name = ?'); $stmt = $this->prepare('SELECT CONVERT(VARCHAR(MAX), current_value) FROM sys.sequences WHERE name = ?');
$stmt->execute([$name]); $stmt->execute([$name]);
} else {
return $stmt->fetchColumn(); $stmt = $this->query('SELECT @@IDENTITY');
} }
return $this->lastInsertId->getId(); return $stmt->fetchColumn();
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment