Made more changes as per review

This commit is contained in:
Jenny Tam 2017-12-05 13:43:53 -08:00
parent 69793cdafc
commit cf9e54fb74
10 changed files with 26 additions and 40 deletions

View file

@ -9,7 +9,7 @@ This test is similar to the other test TC33_ComplexQuery but using UTF-8 data
<?php <?php
require_once('MsCommon.inc'); require_once('MsCommon.inc');
function insertTest($conn, $tableName, $inputs, $query = null) function insertTest($conn, $tableName, $inputs, $query)
{ {
$stmt = null; $stmt = null;
if (!AE\isColEncrypted()) { if (!AE\isColEncrypted()) {

View file

@ -1,7 +1,7 @@
--TEST-- --TEST--
Test using sqlsrv_query for binding parameters with column encryption and a custom keystore provider Test using sqlsrv_query for binding parameters with column encryption and a custom keystore provider
--SKIPIF-- --SKIPIF--
<?php require('skipif_not_ksp.inc'); ?> <?php require('skipif_versions_old.inc'); ?>
--FILE-- --FILE--
<?php <?php
class Patient class Patient

View file

@ -153,7 +153,7 @@ function getInputData($index)
try { try {
setup(); setup();
$conn = connect(); $conn = AE\connect();
// Create a temp table that will be automatically dropped once the connection is closed // Create a temp table that will be automatically dropped once the connection is closed
$tableName = 'param_input_variants'; $tableName = 'param_input_variants';

View file

@ -116,8 +116,8 @@ setup();
// connect // connect
$conn = AE\connect(); $conn = AE\connect();
// Create a test table that will be automatically dropped once the connection is closed // Create a test table
$tableName = GetTempTableName('test_output_variants', false); $tableName = 'test_output_variants';
createVariantTable($conn, $tableName); createVariantTable($conn, $tableName);
testOutputParam($conn, $tableName); testOutputParam($conn, $tableName);

View file

@ -12,9 +12,9 @@ function getFirstInputParam()
return array(1, null, null, $intType); return array(1, null, null, $intType);
} }
function MinMaxScale($conn) function minMaxScale($conn)
{ {
$tableName = 'MinMaxScale'; $tableName = 'minMaxScale';
$columns = array(new AE\ColumnMeta('int', 'c1_int'), $columns = array(new AE\ColumnMeta('int', 'c1_int'),
new AE\ColumnMeta('decimal(28,4)', 'c2_decimal'), new AE\ColumnMeta('decimal(28,4)', 'c2_decimal'),
new AE\ColumnMeta('numeric(32,4)', 'c3_numeric')); new AE\ColumnMeta('numeric(32,4)', 'c3_numeric'));
@ -31,9 +31,9 @@ function MinMaxScale($conn)
dropTable($conn, $tableName); dropTable($conn, $tableName);
} }
function MinMaxSize($conn) function minMaxSize($conn)
{ {
$tableName = 'MinMaxSize'; $tableName = 'minMaxSize';
$columns = array(new AE\ColumnMeta('int', 'c1_int'), $columns = array(new AE\ColumnMeta('int', 'c1_int'),
new AE\ColumnMeta('varchar(max)', 'c2_varchar_max')); new AE\ColumnMeta('varchar(max)', 'c2_varchar_max'));
$stmt = AE\createTable($conn, $tableName, $columns); $stmt = AE\createTable($conn, $tableName, $columns);
@ -49,9 +49,9 @@ function MinMaxSize($conn)
dropTable($conn, $tableName); dropTable($conn, $tableName);
} }
function MinMaxPrecision($conn) function minMaxPrecision($conn)
{ {
$tableName = 'MinMaxPrecision'; $tableName = 'minMaxPrecision';
$columns = array(new AE\ColumnMeta('int', 'c1_int'), $columns = array(new AE\ColumnMeta('int', 'c1_int'),
new AE\ColumnMeta('decimal(28,4)', 'c2_decimal'), new AE\ColumnMeta('decimal(28,4)', 'c2_decimal'),
new AE\ColumnMeta('numeric(32,4)', 'c3_numeric')); new AE\ColumnMeta('numeric(32,4)', 'c3_numeric'));
@ -76,9 +76,9 @@ try {
// connect // connect
$conn = AE\connect(); $conn = AE\connect();
MinMaxScale($conn); minMaxScale($conn);
MinMaxSize($conn); minMaxSize($conn);
MinMaxPrecision($conn); minMaxPrecision($conn);
sqlsrv_close($conn); sqlsrv_close($conn);
} catch (Exception $e) { } catch (Exception $e) {

View file

@ -66,15 +66,18 @@ try {
sqlsrv_configure('WarningsReturnAsErrors', 1); sqlsrv_configure('WarningsReturnAsErrors', 1);
// connect // connect
$conn = connect(); $conn = AE\connect();
if (!$conn) {
fatalError("Could not connect.\n");
}
// create a test table // create a test table
$tableName = 'null_binary_stream'; $tableName = 'null_binary_stream';
$stmt = sqlsrv_query($conn, "CREATE TABLE $tableName ([c1_int] int, [c2_varbinary] varbinary(512), [c3_varbinary_max] varbinary(max), [c4_image] image)"); $columns = array(new AE\ColumnMeta('int', 'c1_int'),
sqlsrv_free_stmt($stmt); new AE\ColumnMeta('varbinary(512)', 'c2_varbinary'),
new AE\ColumnMeta('varbinary(max)', 'c3_varbinary_max'),
new AE\ColumnMeta('image', 'c4_image'));
$stmt = AE\createTable($conn, $tableName, $columns);
if (!$stmt) {
fatalError("Failed to create table.\n");
}
nullBin2String($conn, $tableName); nullBin2String($conn, $tableName);
nullPrepBin2String($conn, $tableName); nullPrepBin2String($conn, $tableName);

View file

@ -17,7 +17,7 @@ $tableName = 'testLOBTypes_GH231_lob';
$columnNames = array("c1", "c2"); $columnNames = array("c1", "c2");
for ($k = 1; $k <= 3; $k++) { for ($k = 1; $k <= 3; $k++) {
$sqlType = getFieldType($k); $sqlType = SQLType($k);
$columns = array(new AE\ColumnMeta('int', $columnNames[0]), $columns = array(new AE\ColumnMeta('int', $columnNames[0]),
new AE\ColumnMeta($sqlType, $columnNames[1])); new AE\ColumnMeta($sqlType, $columnNames[1]));
AE\createTable($conn, $tableName, $columns); AE\createTable($conn, $tableName, $columns);
@ -91,7 +91,7 @@ function getData($k)
return $data; return $data;
} }
function getFieldType($k) function SQLType($k)
{ {
switch ($k) { switch ($k) {
case 1: return ("text"); case 1: return ("text");

View file

@ -20,10 +20,6 @@ for ($k = 1; $k <= 8; $k++) {
new AE\ColumnMeta($sqlType, $columnNames[1])); new AE\ColumnMeta($sqlType, $columnNames[1]));
AE\createTable($conn, $tableName, $columns); AE\createTable($conn, $tableName, $columns);
// $sql = "CREATE TABLE [$tableName] ($dataType)";
// $stmt1 = sqlsrv_query($conn, $sql);
// sqlsrv_free_stmt($stmt1);
$sql = "INSERT INTO [$tableName] ($columnNames[0], $columnNames[1]) VALUES (?, ?)"; $sql = "INSERT INTO [$tableName] ($columnNames[0], $columnNames[1]) VALUES (?, ?)";
$data = getData($k); $data = getData($k);
$phpType = getPhpType($k); $phpType = getPhpType($k);

View file

@ -10,9 +10,6 @@ Send an empty stream and null stream test.
require_once("MsCommon.inc"); require_once("MsCommon.inc");
$conn = AE\connect(); $conn = AE\connect();
// if (!$conn) {
// fatalError("sqlsrv_connect failed.");
// }
$tableName = 'test_empty_stream'; $tableName = 'test_empty_stream';
$columns = array(new AE\ColumnMeta('int', 'id'), $columns = array(new AE\ColumnMeta('int', 'id'),
@ -23,16 +20,6 @@ Send an empty stream and null stream test.
fatalError("Failed to create table $tableName\n"); fatalError("Failed to create table $tableName\n");
} }
// $stmt = sqlsrv_query($conn, "IF OBJECT_ID('test_empty_stream', 'U') IS NOT NULL DROP TABLE test_empty_stream");
// if ($stmt !== false) {
// sqlsrv_free_stmt($stmt);
// }
// $stmt = sqlsrv_query($conn, "CREATE TABLE $tableName (id int, varchar_stream varchar(max), varbinary_stream varbinary(max))");
// if ($stmt === false) {
// die(print_r(sqlsrv_errors(), true));
// }
$f1 = 1; $f1 = 1;
$f2 = fopen("data://text/plain,", "r"); $f2 = fopen("data://text/plain,", "r");
$stmt = sqlsrv_prepare($conn, "INSERT INTO $tableName (id, varchar_stream) VALUES (?, ?)", array( &$f1, &$f2 )); $stmt = sqlsrv_prepare($conn, "INSERT INTO $tableName (id, varchar_stream) VALUES (?, ?)", array( &$f1, &$f2 ));

View file

@ -105,7 +105,7 @@ error messages when trying to retrieve past the end of a result set and when no
} }
print_r(sqlsrv_errors()); print_r(sqlsrv_errors());
sqlsrv_query($conn, "DROP TABLE $tableName"); dropTable($conn, $tableName);
sqlsrv_free_stmt($stmt); sqlsrv_free_stmt($stmt);
sqlsrv_close($conn); sqlsrv_close($conn);