address review comments

This commit is contained in:
v-kaywon 2017-11-03 14:35:16 -07:00
parent 529c5aa77b
commit 0c74a27186
6 changed files with 42 additions and 38 deletions

View file

@ -18,7 +18,7 @@ try {
if (stristr($info, "PDO support => enabled") === false) {
printf("PDO is not enabled\n");
} elseif (stristr($info, "pdo_sqlsrv support => enabled") === false) {
printf("Cannot find PDO driver line in phpinfo() output\n");
printf("Cannot find PDO_SQLSRV driver in phpinfo() output\n");
} else {
printf("Done\n");
}

View file

@ -11,7 +11,7 @@ PHPT_EXEC=true
require_once("MsCommon_mid-refactor.inc");
try {
$conn1 = connect();
checkError(1, $conn1, '00000');
checkError(1, $conn1);
// Prepare test table
$table1 = "Table1";
@ -37,10 +37,11 @@ try {
echo $e->getMessage();
}
function checkError($offset, &$obj, $expected = '00000')
function checkError($offset, &$obj)
{
$code = $obj->errorCode();
if (($code != $expected) && (($expected != '00000') || ($code !=''))) {
$expected = '00000';
if ($code != $expected && !empty($code)) {
printf("[%03d] Expecting error code '%s' got code '%s'\n", $offset, $expected, $code);
}
}

View file

@ -29,7 +29,7 @@ try {
$stmt1->closeCursor();
dropTable($conn1, $table1);
$stmt1->execute();
@$stmt1->execute();
checkError(5, $conn1);
checkError(6, $stmt1, '42S02');
checkError(7, $stmt2, '42S02');
@ -76,7 +76,7 @@ function checkError($offset, &$obj, $expected = '00000')
printf("[%03d] Driver-specific error code not set\n", $offset);
}
if (!isset($info[2]) || ($info[2] == '')) {
printf("[%03d] Driver-specific error message.not set\n", $offset);
printf("[%03d] Driver-specific error message not set\n", $offset);
}
}
}

View file

@ -14,38 +14,39 @@ $tableName2 = "test_connres2";
// from AppVeyor does not have AdventureWorks.
function generateTables($server, $uid, $pwd, $dbName, $tableName1, $tableName2)
{
$conn = new PDO("sqlsrv:server = $server ; Database = $dbName ;", $uid, $pwd);
if ($conn === false) {
die(print_r(sqlsrv_errors()));
try {
$conn = new PDO("sqlsrv:server = $server ; Database = $dbName ;", $uid, $pwd);
// Create table
$sql = "CREATE TABLE $tableName1 (c1 INT, c2 VARCHAR(40))";
$stmt = $conn->query($sql);
// Insert data
$sql = "INSERT INTO $tableName1 VALUES ( ?, ? )";
for ($t = 100; $t < 116; $t++) {
$stmt = $conn->prepare($sql);
$ts = substr(sha1($t), 0, 5);
$params = array( $t,$ts );
$stmt->execute($params);
}
// Create table
$sql = "CREATE TABLE $tableName2 ( c1 INT, c2 VARCHAR(40) )";
$stmt = $conn->query($sql);
// Insert data
$sql = "INSERT INTO $tableName2 VALUES ( ?, ? )";
for ($t = 200; $t < 209; $t++) {
$stmt = $conn->prepare($sql);
$ts = substr(sha1($t), 0, 5);
$params = array( $t,$ts );
$stmt->execute($params);
}
unset($conn);
} catch (PDOException $e) {
var_dump($e->errorInfo);
}
// Create table
$sql = "CREATE TABLE $tableName1 ( c1 INT, c2 VARCHAR(40) )";
$stmt = $conn->query($sql);
// Insert data
$sql = "INSERT INTO $tableName1 VALUES ( ?, ? )";
for ($t = 100; $t < 116; $t++) {
$stmt = $conn->prepare($sql);
$ts = substr(sha1($t), 0, 5);
$params = array( $t,$ts );
$stmt->execute($params);
}
// Create table
$sql = "CREATE TABLE $tableName2 ( c1 INT, c2 VARCHAR(40) )";
$stmt = $conn->query($sql);
// Insert data
$sql = "INSERT INTO $tableName2 VALUES ( ?, ? )";
for ($t = 200; $t < 209; $t++) {
$stmt = $conn->prepare($sql);
$ts = substr(sha1($t), 0, 5);
$params = array( $t,$ts );
$stmt->execute($params);
}
$conn = null;
}
// Break connection by getting the session ID and killing it.

View file

@ -31,6 +31,8 @@ $conn_break = connect();
$connectionInfo = "ConnectRetryCount = 10; ConnectRetryInterval = 10;";
try {
// TODO: Idle connection resiliency does not work with Column Encryption at this point
// Do not connect with ColumnEncryption for now
$conn = connect($connectionInfo, array(), PDO::ERRMODE_EXCEPTION, true);
} catch (PDOException $e) {
echo "Could not connect.\n";

View file

@ -12,7 +12,7 @@ try {
$tbname = "PDO_MainTypes";
createTableMainTypes($db, $tbname);
// query with a wrong column name.
$db->query("Select * from " . $tbname . " where IntColX = 1");
$db->query("SELECT * FROM $tbname WHERE IntColX = 1");
dropTable($db, $tbname);
unset($conn);