php-sqlsrv/test/pdo_sqlsrv/isPooled.php
ulvii 6809f0f7ea Workaround for a bug in unixODBC 2.3.4 (#334)
* Adding a workaround for the error handling issue with unixODBC 2.3.4 when conneciton pooling is enabled

* Adding a check to apply the workaround only to PDO SQLSRV

* Update core_util.cpp

* Unix Conn Pool test

* Modifying the test to use autonomous_setup.php

* Updating path to isPooled.php
2017-03-27 14:07:43 -07:00

26 lines
599 B
PHP

<?php
include_once 'autonomous_setup.php';
$conn1 = new PDO("sqlsrv:Server=$serverName", $username, $password);
$connId1 = ConnectionID($conn1);
$conn1 = null;
$conn2 = new PDO("sqlsrv:Server=$serverName", $username, $password);
$connId2 = ConnectionID($conn2);
if ($connId1 === $connId2){
echo "Pooled\n";
}else{
echo "Not Pooled\n";
}
function ConnectionID($conn)
{
$tsql = "SELECT [connection_id] FROM [sys].[dm_exec_connections] where session_id = @@SPID";
$stmt = $conn->query($tsql);
$connID = $stmt->fetchColumn(0);
$stmt->closeCursor();
$stmt = null;
return ($connID);
}
?>