Skip to content

Commit 3dde4da

Browse files
committed
Do not use double quotes where not necessary
1 parent 739c924 commit 3dde4da

File tree

11 files changed

+136
-136
lines changed

11 files changed

+136
-136
lines changed

samples/tutorials/php/1.0 PHP Configuration and Getting Started/test.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?php
22
echo "\n";
3-
$serverName = "tcp:yourserver.database.windows.net,1433";
3+
$serverName = 'tcp:yourserver.database.windows.net,1433';
44

55
$connectionOptions = [
6-
"Database" => "yourpassword",
7-
"Uid" => "yourusername",
8-
"PWD" => "yourpassword",
6+
'Database' => 'yourpassword',
7+
'Uid' => 'yourusername',
8+
'PWD' => 'yourpassword',
99
];
1010

1111
$conn = sqlsrv_connect($serverName, $connectionOptions);
1212

13-
$tsql = "SELECT [CompanyName] FROM SalesLT.Customer";
13+
$tsql = 'SELECT [CompanyName] FROM SalesLT.Customer';
1414

1515
$getProducts = sqlsrv_query($conn, $tsql);
1616

@@ -23,7 +23,7 @@
2323
while ($row = sqlsrv_fetch_array($getProducts, SQLSRV_FETCH_ASSOC)) {
2424
$ctr++;
2525
echo($row['CompanyName']);
26-
echo("<br/>");
26+
echo('<br/>');
2727
$productCount++;
2828
if ($ctr > 10) {
2929
break;
@@ -46,8 +46,8 @@
4646
}
4747
sqlsrv_free_stmt($insertReview);
4848

49-
$tsql = "DELETE FROM [SalesLT].[Product] WHERE Name=?";
50-
$params = ["SQL Server 15"];
49+
$tsql = 'DELETE FROM [SalesLT].[Product] WHERE Name=?';
50+
$params = ['SQL Server 15'];
5151

5252
$deleteReview = sqlsrv_prepare($conn, $tsql, $params);
5353
if ($deleteReview == false) {

samples/tutorials/php/2.0 PHP Server programming - Stored procedures, Transactions, and UDFs/test.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
2-
$serverName = "tcp:yourserver.database.windows.net,1433";
2+
$serverName = 'tcp:yourserver.database.windows.net,1433';
33
$connectionOptions = [
4-
"Database" => "yourdatabase",
5-
"Uid" => "yourusername",
6-
"PWD" => "yourpassword",
4+
'Database' => 'yourdatabase',
5+
'Uid' => 'yourusername',
6+
'PWD' => 'yourpassword',
77
];
88
// Establishes the connection
99
$conn = sqlsrv_connect($serverName, $connectionOptions);
@@ -12,20 +12,20 @@
1212
* Stored Procedure
1313
*/
1414

15-
$tsql = "CREATE PROCEDURE sp_GetCompanies22 AS BEGIN SELECT [CompanyName] FROM SalesLT.Customer END";
15+
$tsql = 'CREATE PROCEDURE sp_GetCompanies22 AS BEGIN SELECT [CompanyName] FROM SalesLT.Customer END';
1616
$storedProc = sqlsrv_query($conn, $tsql);
1717
if ($storedProc == false) {
18-
echo "Error creating Stored Procedure";
18+
echo 'Error creating Stored Procedure';
1919
die(formatErrors(sqlsrv_errors()));
2020
}
2121
sqlsrv_free_stmt($storedProc);
2222

23-
$tsql = "exec sp_GETCompanies22";
23+
$tsql = 'exec sp_GETCompanies22';
2424
// Executes the query
2525
$getProducts = sqlsrv_query($conn, $tsql);
2626
// Error handling
2727
if ($getProducts == false) {
28-
echo "Error executing Stored Procedure";
28+
echo 'Error executing Stored Procedure';
2929
die(formatErrors(sqlsrv_errors()));
3030
}
3131
$productCount = 0;
@@ -40,15 +40,15 @@
4040
}
4141
$ctr++;
4242
echo($row['CompanyName']);
43-
echo("<br/>");
43+
echo('<br/>');
4444
$productCount++;
4545
}
4646
sqlsrv_free_stmt($getProducts);
47-
$tsql = "DROP PROCEDURE sp_GETCompanies22";
47+
$tsql = 'DROP PROCEDURE sp_GETCompanies22';
4848

4949
$storedProc = sqlsrv_query($conn, $tsql);
5050
if ($storedProc == false) {
51-
echo "Error dropping Stored Procedure";
51+
echo 'Error dropping Stored Procedure';
5252
die(formatErrors(sqlsrv_errors()));
5353
}
5454
sqlsrv_free_stmt($storedProc);
@@ -59,18 +59,18 @@
5959
*/
6060

6161
if (sqlsrv_begin_transaction($conn) == false) {
62-
echo "Error opening connection";
62+
echo 'Error opening connection';
6363
die(formatErrors(sqlsrv_errors()));
6464
}
6565

6666
/* Set up and execute the first query. */
67-
$tsql1 = "INSERT INTO SalesLT.SalesOrderDetail
67+
$tsql1 = 'INSERT INTO SalesLT.SalesOrderDetail
6868
(SalesOrderID,OrderQty,ProductID,UnitPrice)
69-
VALUES (71774, 22, 709, 33)";
69+
VALUES (71774, 22, 709, 33)';
7070
$stmt1 = sqlsrv_query($conn, $tsql1);
7171

7272
/* Set up and execute the second query. */
73-
$tsql2 = "UPDATE SalesLT.SalesOrderDetail SET OrderQty = (OrderQty + 1) WHERE ProductID = 709";
73+
$tsql2 = 'UPDATE SalesLT.SalesOrderDetail SET OrderQty = (OrderQty + 1) WHERE ProductID = 709';
7474
$stmt2 = sqlsrv_query($conn, $tsql2);
7575

7676
/* If both queries were successful, commit the transaction. */
@@ -100,7 +100,7 @@
100100
$getProducts = sqlsrv_query($conn, $tsql1);
101101
// Error handling
102102
if ($getProducts == false) {
103-
echo "Error deleting the UDF";
103+
echo 'Error deleting the UDF';
104104
die(formatErrors(sqlsrv_errors()));
105105
}
106106
$tsql1 = 'CREATE FUNCTION dbo.ifGetTotalItems (@OrderID INT) RETURNS TABLE WITH SCHEMABINDING AS RETURN (
@@ -111,26 +111,26 @@
111111
$getProducts = sqlsrv_query($conn, $tsql1);
112112
// Error handling
113113
if ($getProducts == false) {
114-
echo "Error creating the UDF";
114+
echo 'Error creating the UDF';
115115
die(formatErrors(sqlsrv_errors()));
116116
}
117-
$tsql1 = "SELECT s.SalesOrderID, s.OrderDate, s.CustomerID, f.TotalItems
117+
$tsql1 = 'SELECT s.SalesOrderID, s.OrderDate, s.CustomerID, f.TotalItems
118118
FROM SalesLT.SalesOrderHeader s
119119
CROSS APPLY dbo.ifGetTotalItems(s.SalesOrderID) f
120-
ORDER BY SalesOrderID;";
120+
ORDER BY SalesOrderID;';
121121
$getProducts = sqlsrv_query($conn, $tsql1);
122122
// Error handling
123123
if ($getProducts == false) {
124-
echo "Error executing the UDF";
124+
echo 'Error executing the UDF';
125125
die(formatErrors(sqlsrv_errors()));
126126
}
127127
$productCount = 0;
128128
$ctr = 0;
129129
?>
130130
<h1> First 10 results are after executing a query that uses the UDF: </h1>
131131
<?php
132-
echo "SalesOrderID CustomerID TotalItems";
133-
echo("<br/>");
132+
echo 'SalesOrderID CustomerID TotalItems';
133+
echo('<br/>');
134134

135135
while ($row = sqlsrv_fetch_array($getProducts, SQLSRV_FETCH_ASSOC)) {
136136
// Printing only the top 10 results
@@ -142,7 +142,7 @@
142142
'&nbsp;',
143143
11
144144
) . $row['TotalItems'];
145-
echo("<br/>");
145+
echo('<br/>');
146146
$productCount++;
147147
}
148148
sqlsrv_free_stmt($getProducts);

samples/tutorials/php/RHEL/SqlServerColumnstoreSample/columnstore.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<?php
22
$timeStart = microtime(true);
33

4-
$serverName = "localhost";
4+
$serverName = 'localhost';
55
$connectionOptions = [
6-
"Database" => "SampleDB",
7-
"Uid" => "sa",
8-
"PWD" => "your_password",
6+
'Database' => 'SampleDB',
7+
'Uid' => 'sa',
8+
'PWD' => 'your_password',
99
];
1010
// Establishes the connection
1111
$conn = sqlsrv_connect($serverName, $connectionOptions);
1212

1313
// Read Query
14-
$tsql = "SELECT SUM(Price) as sum FROM Table_with_5M_rows";
14+
$tsql = 'SELECT SUM(Price) as sum FROM Table_with_5M_rows';
1515
$getResults = sqlsrv_query($conn, $tsql);
16-
echo("Sum: ");
16+
echo('Sum: ');
1717
if ($getResults == false) {
1818
die(formatErrors(sqlsrv_errors()));
1919
}
@@ -25,12 +25,12 @@
2525
function formatErrors($errors)
2626
{
2727
/* Display errors. */
28-
echo "Error information: ";
28+
echo 'Error information: ';
2929

3030
foreach ($errors as $error) {
31-
echo "SQLSTATE: " . $error['SQLSTATE'] . "";
32-
echo "Code: " . $error['code'] . "";
33-
echo "Message: " . $error['message'] . "";
31+
echo 'SQLSTATE: ' . $error['SQLSTATE'] . '';
32+
echo 'Code: ' . $error['code'] . '';
33+
echo 'Message: ' . $error['message'] . '';
3434
}
3535
}
3636

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
2-
$serverName = "localhost";
2+
$serverName = 'localhost';
33
$connectionOptions = [
4-
"Database" => "SampleDB",
5-
"Uid" => "sa",
6-
"PWD" => "your_password",
4+
'Database' => 'SampleDB',
5+
'Uid' => 'sa',
6+
'PWD' => 'your_password',
77
];
88
// Establishes the connection
99
$conn = sqlsrv_connect($serverName, $connectionOptions);
1010
if ($conn) {
11-
echo "Connected!";
11+
echo 'Connected!';
1212
}
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,74 @@
11
<?php
2-
$serverName = "localhost";
2+
$serverName = 'localhost';
33
$connectionOptions = [
4-
"Database" => "SampleDB",
5-
"Uid" => "sa",
6-
"PWD" => "your_password",
4+
'Database' => 'SampleDB',
5+
'Uid' => 'sa',
6+
'PWD' => 'your_password',
77
];
88
// Establishes the connection
99
$conn = sqlsrv_connect($serverName, $connectionOptions);
1010

1111
// Insert Query
12-
echo("Inserting a new row into table" . PHP_EOL);
13-
$tsql = "INSERT INTO TestSchema.Employees (Name, Location) VALUES (?,?);";
12+
echo('Inserting a new row into table' . PHP_EOL);
13+
$tsql = 'INSERT INTO TestSchema.Employees (Name, Location) VALUES (?,?);';
1414
$params = ['Jake', 'United States'];
1515
$getResults = sqlsrv_query($conn, $tsql, $params);
1616
$rowsAffected = sqlsrv_rows_affected($getResults);
1717
if ($getResults == false || $rowsAffected == false) {
1818
die(formatErrors(sqlsrv_errors()));
1919
}
20-
echo($rowsAffected . " row(s) inserted: " . PHP_EOL);
20+
echo($rowsAffected . ' row(s) inserted: ' . PHP_EOL);
2121

2222
sqlsrv_free_stmt($getResults);
2323

2424
// Update Query
2525

2626
$userToUpdate = 'Nikita';
27-
$tsql = "UPDATE TestSchema.Employees SET Location = ? WHERE Name = ?";
27+
$tsql = 'UPDATE TestSchema.Employees SET Location = ? WHERE Name = ?';
2828
$params = ['Sweeden', $userToUpdate];
29-
echo("Updating Location for user " . $userToUpdate . PHP_EOL);
29+
echo('Updating Location for user ' . $userToUpdate . PHP_EOL);
3030

3131
$getResults = sqlsrv_query($conn, $tsql, $params);
3232
$rowsAffected = sqlsrv_rows_affected($getResults);
3333
if ($getResults == false || $rowsAffected == false) {
3434
die(formatErrors(sqlsrv_errors()));
3535
}
36-
echo($rowsAffected . " row(s) updated: " . PHP_EOL);
36+
echo($rowsAffected . ' row(s) updated: ' . PHP_EOL);
3737
sqlsrv_free_stmt($getResults);
3838

3939
// Delte Query
4040
$userToDelete = 'Jared';
41-
$tsql = "DELETE FROM TestSchema.Employees WHERE Name = ?";
41+
$tsql = 'DELETE FROM TestSchema.Employees WHERE Name = ?';
4242
$params = [$userToDelete];
4343
$getResults = sqlsrv_query($conn, $tsql, $params);
44-
echo("Deleting user " . $userToDelete . PHP_EOL);
44+
echo('Deleting user ' . $userToDelete . PHP_EOL);
4545
$rowsAffected = sqlsrv_rows_affected($getResults);
4646
if ($getResults == false || $rowsAffected == false) {
4747
die(formatErrors(sqlsrv_errors()));
4848
}
49-
echo($rowsAffected . " row(s) deleted: " . PHP_EOL);
49+
echo($rowsAffected . ' row(s) deleted: ' . PHP_EOL);
5050
sqlsrv_free_stmt($getResults);
5151

5252
// Read Query
53-
$tsql = "SELECT Id, Name, Location FROM TestSchema.Employees;";
53+
$tsql = 'SELECT Id, Name, Location FROM TestSchema.Employees;';
5454
$getResults = sqlsrv_query($conn, $tsql);
55-
echo("Reading data from table" . PHP_EOL);
55+
echo('Reading data from table' . PHP_EOL);
5656
if ($getResults == false) {
5757
die(formatErrors(sqlsrv_errors()));
5858
}
5959
while ($row = sqlsrv_fetch_array($getResults, SQLSRV_FETCH_ASSOC)) {
60-
echo($row['Id'] . " " . $row['Name'] . " " . $row['Location'] . PHP_EOL);
60+
echo($row['Id'] . ' ' . $row['Name'] . ' ' . $row['Location'] . PHP_EOL);
6161
}
6262
sqlsrv_free_stmt($getResults);
6363

6464
function formatErrors($errors)
6565
{
6666
/* Display errors. */
67-
echo "Error information: ";
67+
echo 'Error information: ';
6868

6969
foreach ($errors as $error) {
70-
echo "SQLSTATE: " . $error['SQLSTATE'] . "";
71-
echo "Code: " . $error['code'] . "";
72-
echo "Message: " . $error['message'] . "";
70+
echo 'SQLSTATE: ' . $error['SQLSTATE'] . '';
71+
echo 'Code: ' . $error['code'] . '';
72+
echo 'Message: ' . $error['message'] . '';
7373
}
7474
}

samples/tutorials/php/Ubuntu/SqlServerColumnstoreSample/columnstore.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<?php
22
$timeStart = microtime(true);
33

4-
$serverName = "localhost";
4+
$serverName = 'localhost';
55
$connectionOptions = [
6-
"Database" => "SampleDB",
7-
"Uid" => "sa",
8-
"PWD" => "your_password",
6+
'Database' => 'SampleDB',
7+
'Uid' => 'sa',
8+
'PWD' => 'your_password',
99
];
1010
// Establishes the connection
1111
$conn = sqlsrv_connect($serverName, $connectionOptions);
1212

1313
// Read Query
14-
$tsql = "SELECT SUM(Price) as sum FROM Table_with_5M_rows";
14+
$tsql = 'SELECT SUM(Price) as sum FROM Table_with_5M_rows';
1515
$getResults = sqlsrv_query($conn, $tsql);
16-
echo("Sum: ");
16+
echo('Sum: ');
1717
if ($getResults == false) {
1818
die(formatErrors(sqlsrv_errors()));
1919
}
@@ -25,12 +25,12 @@
2525
function formatErrors($errors)
2626
{
2727
/* Display errors. */
28-
echo "Error information: ";
28+
echo 'Error information: ';
2929

3030
foreach ($errors as $error) {
31-
echo "SQLSTATE: " . $error['SQLSTATE'] . "";
32-
echo "Code: " . $error['code'] . "";
33-
echo "Message: " . $error['message'] . "";
31+
echo 'SQLSTATE: ' . $error['SQLSTATE'] . '';
32+
echo 'Code: ' . $error['code'] . '';
33+
echo 'Message: ' . $error['message'] . '';
3434
}
3535
}
3636

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22
// Setup the connection
3-
$serverName = "localhost";
3+
$serverName = 'localhost';
44
$connectionOptions = [
5-
"Database" => "SampleDB",
6-
"Uid" => "sa",
7-
"PWD" => "your_password"
5+
'Database' => 'SampleDB',
6+
'Uid' => 'sa',
7+
'PWD' => 'your_password'
88
];
99

1010
// Establish the connection
1111
$connection = sqlsrv_connect($serverName, $connectionOptions);
1212
if ($connection) {
13-
echo "Connected!";
13+
echo 'Connected!';
1414
}

0 commit comments

Comments
 (0)