Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
1ea99a2f
Commit
1ea99a2f
authored
Feb 06, 2017
by
Steve Müller
Committed by
Marco Pivetta
Feb 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix fetching last insert ID for sequences on SQL Server
parent
77b764ad
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
Connection.php
lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php
+15
-0
SQLSrvConnection.php
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
+2
-3
No files found.
lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php
View file @
1ea99a2f
...
...
@@ -40,6 +40,21 @@ class Connection extends PDOConnection implements \Doctrine\DBAL\Driver\Connecti
/**
* @override
*/
public
function
lastInsertId
(
$name
=
null
)
{
if
(
null
===
$name
)
{
return
parent
::
lastInsertId
(
$name
);
}
$stmt
=
$this
->
prepare
(
'SELECT CONVERT(VARCHAR(MAX), current_value) FROM sys.sequences WHERE name = ?'
);
$stmt
->
execute
(
array
(
$name
));
return
$stmt
->
fetchColumn
();
}
/**
* {@inheritDoc}
*/
public
function
quote
(
$value
,
$type
=
\PDO
::
PARAM_STR
)
{
$val
=
parent
::
quote
(
$value
,
$type
);
...
...
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
View file @
1ea99a2f
...
...
@@ -130,9 +130,8 @@ class SQLSrvConnection implements Connection, ServerInfoAwareConnection
public
function
lastInsertId
(
$name
=
null
)
{
if
(
$name
!==
null
)
{
$sql
=
"SELECT IDENT_CURRENT("
.
$this
->
quote
(
$name
)
.
") AS LastInsertId"
;
$stmt
=
$this
->
prepare
(
$sql
);
$stmt
->
execute
();
$stmt
=
$this
->
prepare
(
'SELECT CONVERT(VARCHAR(MAX), current_value) FROM sys.sequences WHERE name = ?'
);
$stmt
->
execute
(
array
(
$name
));
return
$stmt
->
fetchColumn
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment