From 7a49fa25bed3b4128d0afe16481043cd2048d852 Mon Sep 17 00:00:00 2001 From: Pavel Kachurka Date: Tue, 10 May 2022 22:52:55 +0200 Subject: [PATCH 1/8] support PDO persistent connection --- src/Phinx/Db/Adapter/PdoAdapter.php | 6 ++++++ tests/Phinx/Db/Adapter/MysqlAdapterTest.php | 12 ++++++++++++ tests/Phinx/Db/Adapter/PostgresAdapterTest.php | 12 ++++++++++++ tests/Phinx/Db/Adapter/SQLiteAdapterTest.php | 12 ++++++++++++ tests/Phinx/Db/Adapter/SqlServerAdapterTest.php | 13 +++++++++++++ 5 files changed, 55 insertions(+) diff --git a/src/Phinx/Db/Adapter/PdoAdapter.php b/src/Phinx/Db/Adapter/PdoAdapter.php index 997aa3702..dae6a9f5d 100644 --- a/src/Phinx/Db/Adapter/PdoAdapter.php +++ b/src/Phinx/Db/Adapter/PdoAdapter.php @@ -80,6 +80,12 @@ protected function createPdoConnection($dsn, $username = null, $password = null, 'attr_errmode' => PDO::ERRMODE_EXCEPTION, ]; + // pass \PDO::ATTR_PERSISTENT to driver options instead of useless setting it after instantiation + if (isset($adapterOptions['attr_persistent'])) { + $options[PDO::ATTR_PERSISTENT] = $adapterOptions['attr_persistent']; + unset($adapterOptions['attr_persistent']); + } + try { $db = new PDO($dsn, $username, $password, $options); diff --git a/tests/Phinx/Db/Adapter/MysqlAdapterTest.php b/tests/Phinx/Db/Adapter/MysqlAdapterTest.php index 26d21df9d..5441d685f 100644 --- a/tests/Phinx/Db/Adapter/MysqlAdapterTest.php +++ b/tests/Phinx/Db/Adapter/MysqlAdapterTest.php @@ -2214,4 +2214,16 @@ public function testGetPhinxTypeFromSQLDefinition(string $sqlDefinition, array $ $this->assertSame($expectedResponse['name'], $result['name'], "Type mismatch - got '{$result['name']}' when expecting '{$expectedResponse['name']}'"); $this->assertSame($expectedResponse['limit'], $result['limit'], "Field upper boundary mismatch - got '{$result['limit']}' when expecting '{$expectedResponse['limit']}'"); } + + public function testPdoPersistentConnection() + { + $adapter = new MysqlAdapter(MYSQL_DB_CONFIG + ['attr_persistent' => true]); + $this->assertEquals(true, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); + } + + public function testPdoNotPersistentConnection() + { + $adapter = new MysqlAdapter(MYSQL_DB_CONFIG); + $this->assertEquals(false, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); + } } diff --git a/tests/Phinx/Db/Adapter/PostgresAdapterTest.php b/tests/Phinx/Db/Adapter/PostgresAdapterTest.php index 47eded3cb..d26af0629 100644 --- a/tests/Phinx/Db/Adapter/PostgresAdapterTest.php +++ b/tests/Phinx/Db/Adapter/PostgresAdapterTest.php @@ -2310,4 +2310,16 @@ public function testInvalidPdoAttribute() $this->expectExceptionMessage('Invalid PDO attribute: attr_invalid (\PDO::ATTR_INVALID)'); $adapter->connect(); } + + public function testPdoPersistentConnection() + { + $adapter = new PostgresAdapter(PGSQL_DB_CONFIG + ['attr_persistent' => true]); + $this->assertEquals(true, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); + } + + public function testPdoNotPersistentConnection() + { + $adapter = new PostgresAdapter(PGSQL_DB_CONFIG); + $this->assertEquals(false, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); + } } diff --git a/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php b/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php index 08c94bee3..203408197 100644 --- a/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php +++ b/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php @@ -2306,4 +2306,16 @@ public function testPdoExceptionUpdateNonExistingTable() $table = new \Phinx\Db\Table('non_existing_table', [], $this->adapter); $table->addColumn('column', 'string')->update(); } + + public function testPdoPersistentConnection() + { + $adapter = new SQLiteAdapter(SQLITE_DB_CONFIG + ['attr_persistent' => true]); + $this->assertEquals(true, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); + } + + public function testPdoNotPersistentConnection() + { + $adapter = new SQLiteAdapter(SQLITE_DB_CONFIG); + $this->assertEquals(false, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); + } } diff --git a/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php b/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php index e1dc21e69..e718e44bd 100644 --- a/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php +++ b/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php @@ -1138,4 +1138,17 @@ public function testInvalidPdoAttribute($attribute) $this->expectExceptionMessage('Invalid PDO attribute: ' . $attribute . ' (\PDO::' . strtoupper($attribute) . ')'); $adapter->connect(); } + + public function testPdoPersistentConnection() + { + $adapter = new SqlServerAdapter(SQLSRV_DB_CONFIG + ['attr_persistent' => true]); + $this->assertEquals(true, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); + } + + public function testPdoNotPersistentConnection() + { + $adapter = new SqlServerAdapter(SQLSRV_DB_CONFIG); + $this->assertEquals(false, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); + } + } From 74a77afd3523ae53130a6057fb8a9e0a320b5ab5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 10 May 2022 22:05:55 +0000 Subject: [PATCH 2/8] Fixing style errors. --- tests/Phinx/Db/Adapter/SqlServerAdapterTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php b/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php index e718e44bd..96094f5c9 100644 --- a/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php +++ b/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php @@ -1150,5 +1150,4 @@ public function testPdoNotPersistentConnection() $adapter = new SqlServerAdapter(SQLSRV_DB_CONFIG); $this->assertEquals(false, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); } - } From 2b860620b4d22eda9d821d43778c731a0f25fc9c Mon Sep 17 00:00:00 2001 From: Pavel Kachurka Date: Wed, 11 May 2022 00:30:43 +0200 Subject: [PATCH 3/8] SQL server PDO driver not supports persistent connections --- src/Phinx/Db/Adapter/MysqlAdapter.php | 5 +++++ src/Phinx/Db/Adapter/PdoAdapter.php | 6 ------ src/Phinx/Db/Adapter/PostgresAdapter.php | 5 +++++ src/Phinx/Db/Adapter/SQLiteAdapter.php | 5 +++++ tests/Phinx/Db/Adapter/SqlServerAdapterTest.php | 12 +++--------- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/Phinx/Db/Adapter/MysqlAdapter.php b/src/Phinx/Db/Adapter/MysqlAdapter.php index 921933a50..009994fcb 100644 --- a/src/Phinx/Db/Adapter/MysqlAdapter.php +++ b/src/Phinx/Db/Adapter/MysqlAdapter.php @@ -132,6 +132,11 @@ public function connect() $driverOptions[PDO::ATTR_DEFAULT_FETCH_MODE] = constant('\PDO::FETCH_' . strtoupper($options['fetch_mode'])); } + // pass \PDO::ATTR_PERSISTENT to driver options instead of useless setting it after instantiation + if (isset($options['attr_persistent'])) { + $driverOptions[PDO::ATTR_PERSISTENT] = $options['attr_persistent']; + } + // support arbitrary \PDO::MYSQL_ATTR_* driver options and pass them to PDO // http://php.net/manual/en/ref.pdo-mysql.php#pdo-mysql.constants foreach ($options as $key => $option) { diff --git a/src/Phinx/Db/Adapter/PdoAdapter.php b/src/Phinx/Db/Adapter/PdoAdapter.php index dae6a9f5d..997aa3702 100644 --- a/src/Phinx/Db/Adapter/PdoAdapter.php +++ b/src/Phinx/Db/Adapter/PdoAdapter.php @@ -80,12 +80,6 @@ protected function createPdoConnection($dsn, $username = null, $password = null, 'attr_errmode' => PDO::ERRMODE_EXCEPTION, ]; - // pass \PDO::ATTR_PERSISTENT to driver options instead of useless setting it after instantiation - if (isset($adapterOptions['attr_persistent'])) { - $options[PDO::ATTR_PERSISTENT] = $adapterOptions['attr_persistent']; - unset($adapterOptions['attr_persistent']); - } - try { $db = new PDO($dsn, $username, $password, $options); diff --git a/src/Phinx/Db/Adapter/PostgresAdapter.php b/src/Phinx/Db/Adapter/PostgresAdapter.php index f510ba97d..7dafad7a2 100644 --- a/src/Phinx/Db/Adapter/PostgresAdapter.php +++ b/src/Phinx/Db/Adapter/PostgresAdapter.php @@ -80,6 +80,11 @@ public function connect() $driverOptions[PDO::ATTR_DEFAULT_FETCH_MODE] = constant('\PDO::FETCH_' . strtoupper($options['fetch_mode'])); } + // pass \PDO::ATTR_PERSISTENT to driver options instead of useless setting it after instantiation + if (isset($options['attr_persistent'])) { + $driverOptions[PDO::ATTR_PERSISTENT] = $options['attr_persistent']; + } + $db = $this->createPdoConnection($dsn, $options['user'] ?? null, $options['pass'] ?? null, $driverOptions); try { diff --git a/src/Phinx/Db/Adapter/SQLiteAdapter.php b/src/Phinx/Db/Adapter/SQLiteAdapter.php index 55d3125b4..2d1e33e4f 100644 --- a/src/Phinx/Db/Adapter/SQLiteAdapter.php +++ b/src/Phinx/Db/Adapter/SQLiteAdapter.php @@ -184,6 +184,11 @@ public function connect() $driverOptions[PDO::ATTR_DEFAULT_FETCH_MODE] = constant('\PDO::FETCH_' . strtoupper($options['fetch_mode'])); } + // pass \PDO::ATTR_PERSISTENT to driver options instead of useless setting it after instantiation + if (isset($options['attr_persistent'])) { + $driverOptions[PDO::ATTR_PERSISTENT] = $options['attr_persistent']; + } + $db = $this->createPdoConnection($dsn, null, null, $driverOptions); $this->setConnection($db); diff --git a/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php b/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php index e718e44bd..1cb11a32b 100644 --- a/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php +++ b/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php @@ -1139,16 +1139,10 @@ public function testInvalidPdoAttribute($attribute) $adapter->connect(); } - public function testPdoPersistentConnection() + public function testPdoSqlSrvNotSupportingPersistentConnections() { $adapter = new SqlServerAdapter(SQLSRV_DB_CONFIG + ['attr_persistent' => true]); - $this->assertEquals(true, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); - } - - public function testPdoNotPersistentConnection() - { - $adapter = new SqlServerAdapter(SQLSRV_DB_CONFIG); - $this->assertEquals(false, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); + $this->expectException(\InvalidArgumentException::class); + $adapter->connect(); } - } From e62466e2467df98a403b615110c7763c71f0557f Mon Sep 17 00:00:00 2001 From: Pavel Kachurka Date: Wed, 11 May 2022 00:38:04 +0200 Subject: [PATCH 4/8] not testing SQL server PDO driver for unsupported attribute --- tests/Phinx/Db/Adapter/SqlServerAdapterTest.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php b/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php index 1cb11a32b..e1dc21e69 100644 --- a/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php +++ b/tests/Phinx/Db/Adapter/SqlServerAdapterTest.php @@ -1138,11 +1138,4 @@ public function testInvalidPdoAttribute($attribute) $this->expectExceptionMessage('Invalid PDO attribute: ' . $attribute . ' (\PDO::' . strtoupper($attribute) . ')'); $adapter->connect(); } - - public function testPdoSqlSrvNotSupportingPersistentConnections() - { - $adapter = new SqlServerAdapter(SQLSRV_DB_CONFIG + ['attr_persistent' => true]); - $this->expectException(\InvalidArgumentException::class); - $adapter->connect(); - } } From bc9f3d7ea7457a22dcd937aa6a060fcb5ca4d6ff Mon Sep 17 00:00:00 2001 From: Pavel Kachurka <91262244+paulermo@users.noreply.github.com> Date: Wed, 11 May 2022 12:40:28 +0200 Subject: [PATCH 5/8] Apply assertTrue & assertFalse suggestions from code review Co-authored-by: Matthew Peveler --- tests/Phinx/Db/Adapter/MysqlAdapterTest.php | 4 ++-- tests/Phinx/Db/Adapter/PostgresAdapterTest.php | 4 ++-- tests/Phinx/Db/Adapter/SQLiteAdapterTest.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Phinx/Db/Adapter/MysqlAdapterTest.php b/tests/Phinx/Db/Adapter/MysqlAdapterTest.php index 5441d685f..3ad63de54 100644 --- a/tests/Phinx/Db/Adapter/MysqlAdapterTest.php +++ b/tests/Phinx/Db/Adapter/MysqlAdapterTest.php @@ -2218,12 +2218,12 @@ public function testGetPhinxTypeFromSQLDefinition(string $sqlDefinition, array $ public function testPdoPersistentConnection() { $adapter = new MysqlAdapter(MYSQL_DB_CONFIG + ['attr_persistent' => true]); - $this->assertEquals(true, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); + $this->assertTrue($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT); } public function testPdoNotPersistentConnection() { $adapter = new MysqlAdapter(MYSQL_DB_CONFIG); - $this->assertEquals(false, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); + $this->assertFalse($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT); } } diff --git a/tests/Phinx/Db/Adapter/PostgresAdapterTest.php b/tests/Phinx/Db/Adapter/PostgresAdapterTest.php index d26af0629..68a887a5f 100644 --- a/tests/Phinx/Db/Adapter/PostgresAdapterTest.php +++ b/tests/Phinx/Db/Adapter/PostgresAdapterTest.php @@ -2314,12 +2314,12 @@ public function testInvalidPdoAttribute() public function testPdoPersistentConnection() { $adapter = new PostgresAdapter(PGSQL_DB_CONFIG + ['attr_persistent' => true]); - $this->assertEquals(true, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); + $this->assertTrue($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT); } public function testPdoNotPersistentConnection() { $adapter = new PostgresAdapter(PGSQL_DB_CONFIG); - $this->assertEquals(false, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); + $this->assertFalse($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT); } } diff --git a/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php b/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php index 203408197..34cc0c677 100644 --- a/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php +++ b/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php @@ -2310,12 +2310,12 @@ public function testPdoExceptionUpdateNonExistingTable() public function testPdoPersistentConnection() { $adapter = new SQLiteAdapter(SQLITE_DB_CONFIG + ['attr_persistent' => true]); - $this->assertEquals(true, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); + $this->assertTrue($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT); } public function testPdoNotPersistentConnection() { $adapter = new SQLiteAdapter(SQLITE_DB_CONFIG); - $this->assertEquals(false, $adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); + $this->assertFalse($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT); } } From ee97d51ff853577b42ae01dbdd8bad4256fcd6da Mon Sep 17 00:00:00 2001 From: Pavel Kachurka Date: Wed, 11 May 2022 12:43:31 +0200 Subject: [PATCH 6/8] syntax fix after applying suggestions --- tests/Phinx/Db/Adapter/MysqlAdapterTest.php | 4 ++-- tests/Phinx/Db/Adapter/PostgresAdapterTest.php | 4 ++-- tests/Phinx/Db/Adapter/SQLiteAdapterTest.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Phinx/Db/Adapter/MysqlAdapterTest.php b/tests/Phinx/Db/Adapter/MysqlAdapterTest.php index 3ad63de54..4842760c3 100644 --- a/tests/Phinx/Db/Adapter/MysqlAdapterTest.php +++ b/tests/Phinx/Db/Adapter/MysqlAdapterTest.php @@ -2218,12 +2218,12 @@ public function testGetPhinxTypeFromSQLDefinition(string $sqlDefinition, array $ public function testPdoPersistentConnection() { $adapter = new MysqlAdapter(MYSQL_DB_CONFIG + ['attr_persistent' => true]); - $this->assertTrue($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT); + $this->assertTrue($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); } public function testPdoNotPersistentConnection() { $adapter = new MysqlAdapter(MYSQL_DB_CONFIG); - $this->assertFalse($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT); + $this->assertFalse($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); } } diff --git a/tests/Phinx/Db/Adapter/PostgresAdapterTest.php b/tests/Phinx/Db/Adapter/PostgresAdapterTest.php index 68a887a5f..a8baa8c2c 100644 --- a/tests/Phinx/Db/Adapter/PostgresAdapterTest.php +++ b/tests/Phinx/Db/Adapter/PostgresAdapterTest.php @@ -2314,12 +2314,12 @@ public function testInvalidPdoAttribute() public function testPdoPersistentConnection() { $adapter = new PostgresAdapter(PGSQL_DB_CONFIG + ['attr_persistent' => true]); - $this->assertTrue($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT); + $this->assertTrue($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); } public function testPdoNotPersistentConnection() { $adapter = new PostgresAdapter(PGSQL_DB_CONFIG); - $this->assertFalse($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT); + $this->assertFalse($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); } } diff --git a/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php b/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php index 34cc0c677..b92e45878 100644 --- a/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php +++ b/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php @@ -2310,12 +2310,12 @@ public function testPdoExceptionUpdateNonExistingTable() public function testPdoPersistentConnection() { $adapter = new SQLiteAdapter(SQLITE_DB_CONFIG + ['attr_persistent' => true]); - $this->assertTrue($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT); + $this->assertTrue($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); } public function testPdoNotPersistentConnection() { $adapter = new SQLiteAdapter(SQLITE_DB_CONFIG); - $this->assertFalse($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT); + $this->assertFalse($adapter->getConnection()->getAttribute(\PDO::ATTR_PERSISTENT)); } } From cff3d7f0a31ba1d5e306a7f7a2111c985b256a24 Mon Sep 17 00:00:00 2001 From: Matthew Peveler Date: Mon, 4 Jul 2022 11:24:04 -0400 Subject: [PATCH 7/8] Update SqlServerAdapter.php --- src/Phinx/Db/Adapter/SqlServerAdapter.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Phinx/Db/Adapter/SqlServerAdapter.php b/src/Phinx/Db/Adapter/SqlServerAdapter.php index d9751087e..95e9c0833 100644 --- a/src/Phinx/Db/Adapter/SqlServerAdapter.php +++ b/src/Phinx/Db/Adapter/SqlServerAdapter.php @@ -88,6 +88,9 @@ public function connect() if (!empty($options['fetch_mode'])) { $driverOptions[PDO::ATTR_DEFAULT_FETCH_MODE] = constant('\PDO::FETCH_' . strtoupper($options['fetch_mode'])); } + + // Note, the PDO::ATTR_PERSISTENT attribute is not supported for sqlsrv and will throw an error when used + // See https://github.com/Microsoft/msphpsql/issues/65 // support arbitrary \PDO::SQLSRV_ATTR_* driver options and pass them to PDO // http://php.net/manual/en/ref.pdo-sqlsrv.php#pdo-sqlsrv.constants From 7d0a7e54876bc0c7e5e7349cac7a423c5689815f Mon Sep 17 00:00:00 2001 From: Matthew Peveler Date: Mon, 4 Jul 2022 11:26:23 -0400 Subject: [PATCH 8/8] Update SqlServerAdapter.php --- src/Phinx/Db/Adapter/SqlServerAdapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Phinx/Db/Adapter/SqlServerAdapter.php b/src/Phinx/Db/Adapter/SqlServerAdapter.php index 95e9c0833..62b3d1ee9 100644 --- a/src/Phinx/Db/Adapter/SqlServerAdapter.php +++ b/src/Phinx/Db/Adapter/SqlServerAdapter.php @@ -88,7 +88,7 @@ public function connect() if (!empty($options['fetch_mode'])) { $driverOptions[PDO::ATTR_DEFAULT_FETCH_MODE] = constant('\PDO::FETCH_' . strtoupper($options['fetch_mode'])); } - + // Note, the PDO::ATTR_PERSISTENT attribute is not supported for sqlsrv and will throw an error when used // See https://github.com/Microsoft/msphpsql/issues/65