diff --git a/src/Driver/SQLSrv/Connection.php b/src/Driver/SQLSrv/Connection.php index 902a1167c74..e37ea9006cd 100644 --- a/src/Driver/SQLSrv/Connection.php +++ b/src/Driver/SQLSrv/Connection.php @@ -27,9 +27,6 @@ final class Connection implements ServerInfoAwareConnection /** @var resource */ protected $conn; - /** @var LastInsertId */ - protected $lastInsertId; - /** * @internal The connection can be only instantiated by its driver. * @@ -50,8 +47,7 @@ public function __construct($serverName, $connectionOptions) throw Error::new(); } - $this->conn = $conn; - $this->lastInsertId = new LastInsertId(); + $this->conn = $conn; } /** @@ -66,7 +62,7 @@ public function getServerVersion() public function prepare(string $sql): DriverStatement { - return new Statement($this->conn, $sql, $this->lastInsertId); + return new Statement($this->conn, $sql); } public function query(string $sql): ResultInterface diff --git a/src/Driver/SQLSrv/LastInsertId.php b/src/Driver/SQLSrv/LastInsertId.php deleted file mode 100644 index 0948e5876b0..00000000000 --- a/src/Driver/SQLSrv/LastInsertId.php +++ /dev/null @@ -1,32 +0,0 @@ -id = $id; - } - - /** - * @return int - */ - public function getId() - { - return $this->id; - } -} diff --git a/src/Driver/SQLSrv/Statement.php b/src/Driver/SQLSrv/Statement.php index ba2e29f9117..8267bc0de7a 100644 --- a/src/Driver/SQLSrv/Statement.php +++ b/src/Driver/SQLSrv/Statement.php @@ -11,9 +11,6 @@ use function assert; use function is_int; use function sqlsrv_execute; -use function sqlsrv_fetch; -use function sqlsrv_get_field; -use function sqlsrv_next_result; use function SQLSRV_PHPTYPE_STREAM; use function SQLSRV_PHPTYPE_STRING; use function sqlsrv_prepare; @@ -61,13 +58,6 @@ final class Statement implements StatementInterface */ private $types = []; - /** - * The last insert ID. - * - * @var LastInsertId|null - */ - private $lastInsertId; - /** * Append to any INSERT query to retrieve the last insert id. */ @@ -79,7 +69,7 @@ final class Statement implements StatementInterface * @param resource $conn * @param string $sql */ - public function __construct($conn, $sql, ?LastInsertId $lastInsertId = null) + public function __construct($conn, $sql) { $this->conn = $conn; $this->sql = $sql; @@ -88,8 +78,7 @@ public function __construct($conn, $sql, ?LastInsertId $lastInsertId = null) return; } - $this->sql .= self::LAST_INSERT_ID_SQL; - $this->lastInsertId = $lastInsertId; + $this->sql .= self::LAST_INSERT_ID_SQL; } /** @@ -144,12 +133,6 @@ public function execute($params = null): ResultInterface throw Error::new(); } - if ($this->lastInsertId !== null) { - sqlsrv_next_result($this->stmt); - sqlsrv_fetch($this->stmt); - $this->lastInsertId->setId(sqlsrv_get_field($this->stmt, 0)); - } - return new Result($this->stmt); }