зеркало из https://github.com/microsoft/msphpsql.git
Conn res fix (#1091)
This commit is contained in:
Родитель
e90fd2c4a4
Коммит
5455b4dcb8
|
@ -52,8 +52,12 @@ function generateTables($server, $uid, $pwd, $dbName, $tableName1, $tableName2)
|
|||
// Break connection by getting the session ID and killing it.
|
||||
// Note that breaking a connection and testing reconnection requires a
|
||||
// TCP/IP protocol connection (as opposed to a Shared Memory protocol).
|
||||
// Wait one second before and after breaking to ensure the break occurs
|
||||
// in the correct order, otherwise there may be timing issues in Linux
|
||||
// that can cause tests to fail intermittently and unpredictably.
|
||||
function breakConnection($conn, $conn_break)
|
||||
{
|
||||
sleep(1);
|
||||
$stmt1 = $conn->query("SELECT @@SPID");
|
||||
$obj = $stmt1->fetch(PDO::FETCH_NUM);
|
||||
$spid = $obj[0];
|
||||
|
|
|
@ -17,8 +17,7 @@ function GenerateTables( $server, $uid, $pwd, $dbName, $tableName1, $tableName2
|
|||
$connectionInfo = array("Database"=>$dbName, "uid"=>$uid, "pwd"=>$pwd);
|
||||
|
||||
$conn = sqlsrv_connect($server, $connectionInfo);
|
||||
if ( $conn === false )
|
||||
{
|
||||
if ($conn === false) {
|
||||
die (print_r(sqlsrv_errors()));
|
||||
}
|
||||
|
||||
|
@ -28,8 +27,7 @@ function GenerateTables( $server, $uid, $pwd, $dbName, $tableName1, $tableName2
|
|||
|
||||
// Insert data
|
||||
$sql = "INSERT INTO $tableName1 VALUES (?, ?)";
|
||||
for( $t = 100; $t < 116; $t++ )
|
||||
{
|
||||
for ($t = 100; $t < 116; $t++) {
|
||||
$ts = substr(sha1($t), 0, 5);
|
||||
$params = array($t, $ts);
|
||||
$stmt = sqlsrv_prepare($conn, $sql, $params);
|
||||
|
@ -42,8 +40,7 @@ function GenerateTables( $server, $uid, $pwd, $dbName, $tableName1, $tableName2
|
|||
|
||||
// Insert data
|
||||
$sql = "INSERT INTO $tableName2 VALUES (?, ?)";
|
||||
for( $t = 200; $t < 209; $t++ )
|
||||
{
|
||||
for ($t = 200; $t < 209; $t++) {
|
||||
$ts = substr(sha1($t), 0, 5);
|
||||
$params = array($t, $ts);
|
||||
$stmt = sqlsrv_prepare($conn, $sql, $params);
|
||||
|
@ -56,11 +53,14 @@ function GenerateTables( $server, $uid, $pwd, $dbName, $tableName1, $tableName2
|
|||
// Break connection by getting the session ID and killing it.
|
||||
// Note that breaking a connection and testing reconnection requires a
|
||||
// TCP/IP protocol connection (as opposed to a Shared Memory protocol).
|
||||
// Wait one second before and after breaking to ensure the break occurs
|
||||
// in the correct order, otherwise there may be timing issues in Linux
|
||||
// that can cause tests to fail intermittently and unpredictably.
|
||||
function BreakConnection($conn, $conn_break)
|
||||
{
|
||||
sleep(1);
|
||||
$stmt1 = sqlsrv_query($conn, "SELECT @@SPID");
|
||||
if ( sqlsrv_fetch( $stmt1 ) )
|
||||
{
|
||||
if (sqlsrv_fetch($stmt1)) {
|
||||
$spid=sqlsrv_get_field($stmt1, 0);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче