-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
32 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,51 +2,51 @@ | |
insert stream. | ||
--SKIPIF-- | ||
--FILE-- | ||
<?php | ||
/* Connect to the local server using Windows Authentication and | ||
specify the AdventureWorks database as the database in use. */ | ||
require('connect.inc'); | ||
$connectionInfo = array( "Database"=>"$databaseName", "UID"=>"$uid", "PWD"=>"$pwd"); | ||
$conn = sqlsrv_connect($server, $connectionInfo); | ||
if ($conn === false) { | ||
echo "Could not connect.\n"; | ||
die(print_r(sqlsrv_errors(), true)); | ||
} | ||
<?php | ||
/* Connect to the local server using Windows Authentication and | ||
specify the AdventureWorks database as the database in use. */ | ||
require('connect.inc'); | ||
$connectionInfo = array( "Database"=>"$databaseName", "UID"=>"$uid", "PWD"=>"$pwd"); | ||
$conn = sqlsrv_connect($server, $connectionInfo); | ||
if ($conn === false) { | ||
echo "Could not connect.\n"; | ||
die(print_r(sqlsrv_errors(), true)); | ||
} | ||
|
||
/* Remove any records with from the table with ProductID = 999*/ | ||
$productID = 999; | ||
$tsql = "DELETE FROM Production.ProductReview WHERE ProductID = $productID"; | ||
sqlsrv_query($conn, $tsql); | ||
|
||
/* Set up the Transact-SQL query. */ | ||
|
||
/* Set up the Transact-SQL query. */ | ||
$tsql = "INSERT INTO Production.ProductReview (ProductID, | ||
ReviewerName, | ||
ReviewDate, | ||
EmailAddress, | ||
Rating, | ||
Comments) | ||
VALUES (?, ?, ?, ?, ?, ?)"; | ||
VALUES (?, ?, ?, ?, ?, ?)"; | ||
|
||
/* Set the parameter values and put them in an array. | ||
Note that $comments is opened as a stream. */ | ||
/* Set the parameter values and put them in an array. | ||
Note that $comments is opened as a stream. */ | ||
|
||
$number = rand(99, 9999); | ||
$input = "[Insert some number $number]"; | ||
|
||
/* There is no record in this table with ProductID = 999 */ | ||
$name = 'Customer Name'; | ||
$date = date("Y-m-d"); | ||
$email = '[email protected]'; | ||
$rating = 3; | ||
$name = 'Customer Name'; | ||
$date = date("Y-m-d"); | ||
$email = '[email protected]'; | ||
$rating = 3; | ||
$comments = fopen("data://text/plain,$input", "r"); | ||
$params = array($productID, $name, $date, $email, $rating, $comments); | ||
|
||
/* Execute the query. All stream data is sent upon execution.*/ | ||
$stmt = sqlsrv_query($conn, $tsql, $params); | ||
if ($stmt === false) { | ||
echo "Error in statement execution.\n"; | ||
die(print_r(sqlsrv_errors(), true)); | ||
} | ||
$params = array($productID, $name, $date, $email, $rating, $comments); | ||
|
||
/* Execute the query. All stream data is sent upon execution.*/ | ||
$stmt = sqlsrv_query($conn, $tsql, $params); | ||
if ($stmt === false) { | ||
echo "Error in statement execution.\n"; | ||
die(print_r(sqlsrv_errors(), true)); | ||
} | ||
|
||
/* Read it back to check the comment */ | ||
$tsql = "SELECT Comments FROM Production.ProductReview | ||
|
@@ -67,10 +67,10 @@ $tsql = "DELETE FROM Production.ProductReview WHERE ProductID = $productID"; | |
sqlsrv_query($conn, $tsql); | ||
|
||
echo "Done" . PHP_EOL; | ||
|
||
/* Free statement and connection resources. */ | ||
sqlsrv_free_stmt($stmt); | ||
sqlsrv_close($conn); | ||
|
||
/* Free statement and connection resources. */ | ||
sqlsrv_free_stmt($stmt); | ||
sqlsrv_close($conn); | ||
?> | ||
--EXPECT-- | ||
The query was successfully executed. | ||
Done |