Skip to content

Commit

Permalink
Fixed fetching last inserted ID from a SQL Server connection
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Mar 16, 2018
1 parent b1953ea commit cadd79c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ public function lastInsertId($name = null)
if ($name !== null) {
$stmt = $this->prepare('SELECT CONVERT(VARCHAR(MAX), current_value) FROM sys.sequences WHERE name = ?');
$stmt->execute([$name]);

return $stmt->fetchColumn();
} else {
$stmt = $this->query('SELECT @@IDENTITY');
}

return $this->lastInsertId->getId();
return $stmt->fetchColumn();
}

/**
Expand Down

0 comments on commit cadd79c

Please sign in to comment.