Skip to content

Commit 42f2fb5

Browse files
Fixed coding style
1 parent 3770d3c commit 42f2fb5

File tree

2 files changed

+46
-50
lines changed

2 files changed

+46
-50
lines changed

test/functional/pdo_sqlsrv/break_pdo.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ function generateTables($server, $uid, $pwd, $dbName, $tableName1, $tableName2)
2222
$stmt = $conn->query($sql);
2323

2424
// Insert data
25-
$sql = "INSERT INTO $tableName1 VALUES ( ?, ? )";
25+
$sql = "INSERT INTO $tableName1 VALUES (?, ?)";
2626
for ($t = 100; $t < 116; $t++) {
2727
$stmt = $conn->prepare($sql);
2828
$ts = substr(sha1($t), 0, 5);
29-
$params = array( $t,$ts );
29+
$params = array($t, $ts);
3030
$stmt->execute($params);
3131
}
3232

3333
// Create table
34-
$sql = "CREATE TABLE $tableName2 ( c1 INT, c2 VARCHAR(40) )";
34+
$sql = "CREATE TABLE $tableName2 (c1 INT, c2 VARCHAR(40))";
3535
$stmt = $conn->query($sql);
3636

3737
// Insert data
38-
$sql = "INSERT INTO $tableName2 VALUES ( ?, ? )";
38+
$sql = "INSERT INTO $tableName2 VALUES (?, ?)";
3939
for ($t = 200; $t < 209; $t++) {
4040
$stmt = $conn->prepare($sql);
4141
$ts = substr(sha1($t), 0, 5);
42-
$params = array( $t,$ts );
42+
$params = array($t, $ts);
4343
$stmt->execute($params);
4444
}
4545

@@ -73,11 +73,11 @@ function dropTables($server, $uid, $pwd, $tableName1, $tableName2)
7373

7474
$conn = new PDO("sqlsrv:server = $server ; Database = $dbName ;", $uid, $pwd);
7575

76-
$query="IF OBJECT_ID('$tableName1', 'U') IS NOT NULL DROP TABLE $tableName1";
77-
$stmt=$conn->query($query);
76+
$query = "IF OBJECT_ID('$tableName1', 'U') IS NOT NULL DROP TABLE $tableName1";
77+
$stmt = $conn->query($query);
7878

79-
$query="IF OBJECT_ID('$tableName2', 'U') IS NOT NULL DROP TABLE $tableName2";
80-
$stmt=$conn->query($query);
79+
$query = "IF OBJECT_ID('$tableName2', 'U') IS NOT NULL DROP TABLE $tableName2";
80+
$stmt = $conn->query($query);
8181
}
8282

8383
dropTables($server, $uid, $pwd, $tableName1, $tableName2);

test/functional/sqlsrv/break.php

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,42 @@
1212
// Using generated tables will eventually allow us to put the
1313
// connection resiliency tests on Github, since the integrated testing
1414
// from AppVeyor does not have AdventureWorks.
15-
function GenerateTables( $server, $uid, $pwd, $dbName, $tableName1, $tableName2 )
15+
function GenerateTables($server, $uid, $pwd, $dbName, $tableName1, $tableName2)
1616
{
17-
$connectionInfo = array( "Database"=>$dbName, "uid"=>$uid, "pwd"=>$pwd );
17+
$connectionInfo = array("Database"=>$dbName, "uid"=>$uid, "pwd"=>$pwd);
1818

19-
$conn = sqlsrv_connect( $server, $connectionInfo );
20-
if ( $conn === false )
21-
{
22-
die ( print_r( sqlsrv_errors() ) );
19+
$conn = sqlsrv_connect($server, $connectionInfo);
20+
if ($conn === false) {
21+
die (print_r(sqlsrv_errors()));
2322
}
2423

2524
// Create table
26-
$sql = "CREATE TABLE $tableName1 ( c1 INT, c2 VARCHAR(40) )";
27-
$stmt = sqlsrv_query( $conn, $sql );
25+
$sql = "CREATE TABLE $tableName1 (c1 INT, c2 VARCHAR(40))";
26+
$stmt = sqlsrv_query($conn, $sql);
2827

2928
// Insert data
30-
$sql = "INSERT INTO $tableName1 VALUES ( ?, ? )";
31-
for( $t = 100; $t < 116; $t++ )
32-
{
33-
$ts = substr( sha1( $t ),0,5 );
34-
$params = array( $t,$ts );
35-
$stmt = sqlsrv_prepare( $conn, $sql, $params );
36-
sqlsrv_execute( $stmt );
29+
$sql = "INSERT INTO $tableName1 VALUES (?, ?)";
30+
for ($t = 100; $t < 116; $t++) {
31+
$ts = substr(sha1($t), 0, 5);
32+
$params = array($t, $ts);
33+
$stmt = sqlsrv_prepare($conn, $sql, $params);
34+
sqlsrv_execute($stmt);
3735
}
3836

3937
// Create table
40-
$sql = "CREATE TABLE $tableName2 ( c1 INT, c2 VARCHAR(40) )";
41-
$stmt = sqlsrv_query( $conn, $sql );
38+
$sql = "CREATE TABLE $tableName2 (c1 INT, c2 VARCHAR(40))";
39+
$stmt = sqlsrv_query($conn, $sql);
4240

4341
// Insert data
44-
$sql = "INSERT INTO $tableName2 VALUES ( ?, ? )";
45-
for( $t = 200; $t < 209; $t++ )
46-
{
47-
$ts = substr( sha1( $t ),0,5 );
48-
$params = array( $t,$ts );
49-
$stmt = sqlsrv_prepare( $conn, $sql, $params );
50-
sqlsrv_execute( $stmt );
42+
$sql = "INSERT INTO $tableName2 VALUES (?, ?)";
43+
for ($t = 200; $t < 209; $t++) {
44+
$ts = substr(sha1($t), 0, 5);
45+
$params = array($t, $ts);
46+
$stmt = sqlsrv_prepare($conn, $sql, $params);
47+
sqlsrv_execute($stmt);
5148
}
5249

53-
sqlsrv_close( $conn );
50+
sqlsrv_close($conn);
5451
}
5552

5653
// Break connection by getting the session ID and killing it.
@@ -59,36 +56,35 @@ function GenerateTables( $server, $uid, $pwd, $dbName, $tableName1, $tableName2
5956
// Wait one second before and after breaking to ensure the break occurs
6057
// in the correct order, otherwise there may be timing issues in Linux
6158
// that can cause tests to fail intermittently and unpredictably.
62-
function BreakConnection( $conn, $conn_break )
59+
function BreakConnection($conn, $conn_break)
6360
{
6461
sleep(1);
65-
$stmt1 = sqlsrv_query( $conn, "SELECT @@SPID" );
66-
if ( sqlsrv_fetch( $stmt1 ) )
67-
{
68-
$spid=sqlsrv_get_field( $stmt1, 0 );
62+
$stmt1 = sqlsrv_query($conn, "SELECT @@SPID");
63+
if (sqlsrv_fetch($stmt1)) {
64+
$spid=sqlsrv_get_field($stmt1, 0);
6965
}
7066

71-
$stmt2 = sqlsrv_prepare( $conn_break, "KILL ".$spid );
72-
sqlsrv_execute( $stmt2 );
67+
$stmt2 = sqlsrv_prepare($conn_break, "KILL ".$spid);
68+
sqlsrv_execute($stmt2);
7369
sleep(1);
7470
}
7571

7672
// Remove the tables generated by GenerateTables
77-
function DropTables( $server, $uid, $pwd, $tableName1, $tableName2 )
73+
function DropTables($server, $uid, $pwd, $tableName1, $tableName2)
7874
{
7975
global $dbName;
8076

81-
$connectionInfo = array( "Database"=>$dbName, "UID"=>$uid, "PWD"=>$pwd );
82-
$conn = sqlsrv_connect( $server, $connectionInfo );
77+
$connectionInfo = array("Database"=>$dbName, "UID"=>$uid, "PWD"=>$pwd);
78+
$conn = sqlsrv_connect($server, $connectionInfo);
8379

84-
$query="IF OBJECT_ID('$tableName1', 'U') IS NOT NULL DROP TABLE $tableName1";
85-
$stmt=sqlsrv_query( $conn, $query );
80+
$query = "IF OBJECT_ID('$tableName1', 'U') IS NOT NULL DROP TABLE $tableName1";
81+
$stmt = sqlsrv_query($conn, $query);
8682

87-
$query="IF OBJECT_ID('$tableName2', 'U') IS NOT NULL DROP TABLE $tableName2";
88-
$stmt=sqlsrv_query( $conn, $query );
83+
$query = "IF OBJECT_ID('$tableName2', 'U') IS NOT NULL DROP TABLE $tableName2";
84+
$stmt = sqlsrv_query($conn, $query);
8985
}
9086

91-
DropTables( $server, $uid, $pwd, $tableName1, $tableName2 );
92-
GenerateTables( $server, $uid, $pwd, $dbName, $tableName1, $tableName2 );
87+
DropTables($server, $uid, $pwd, $tableName1, $tableName2);
88+
GenerateTables($server, $uid, $pwd, $dbName, $tableName1, $tableName2);
9389

9490
?>

0 commit comments

Comments
 (0)