diff --git a/test/functional/sqlsrv/0052.phpt b/test/functional/sqlsrv/0052.phpt index 986e8a75..11ced488 100644 --- a/test/functional/sqlsrv/0052.phpt +++ b/test/functional/sqlsrv/0052.phpt @@ -17,8 +17,13 @@ this test is very similar to test_scrollable.phpt... might consider removing thi $columns = array(new AE\ColumnMeta('int', 'id'), new AE\ColumnMeta('char(10)', 'value')); $stmt = AE\createTable($conn, $tableName, $columns); + if (!$stmt) { + fatalError("Failed to create table for the test]n"); + } sqlsrv_free_stmt($stmt); - + + // Always Encrypted feature only supports SQLSRV_CURSOR_FORWARD or + // SQLSRV_CURSOR_CLIENT_BUFFERED $query = "SELECT * FROM $tableName"; if (AE\isColEncrypted()) { $options = array('Scrollable' => SQLSRV_CURSOR_FORWARD); diff --git a/test/functional/sqlsrv/MsHelper.inc b/test/functional/sqlsrv/MsHelper.inc index a726e93d..a2657146 100644 --- a/test/functional/sqlsrv/MsHelper.inc +++ b/test/functional/sqlsrv/MsHelper.inc @@ -74,7 +74,7 @@ class ColumnMeta if (stripos($this->options, "identity") !== false) { $this->encryptable = false; - } elseif (in_array($this->dataType, $unsupported)) { + } elseif (in_array(strtolower($this->dataType), $unsupported)) { $this->encryptable = false; } else { $this->encryptable = true; @@ -381,36 +381,6 @@ function createTable($conn, $tbname, $columnMetaArr) return sqlsrv_query($conn, $createSql); } -/** - * Create a table with options for sqlsrv_prepare() - * @param resource $conn : sqlsrv connection resource - * @param string $tbname : name of the table to be created - * @param array $columnMetaArr : array of ColumnMeta objects, which contain metadata for one column - * @param array $options : array of options for sqlsrv_prepare() - * @return resource sqlsrv statement resource - */ -function createTableEx($conn, $tbname, $columnMetaArr, $options) -{ - require_once("MsCommon.inc"); - dropTable($conn, $tbname); - $colDef = ""; - foreach ($columnMetaArr as $meta) { - $colDef = $colDef . $meta->getColDef() . ", "; - } - $colDef = rtrim($colDef, ", "); - $createSql = "CREATE TABLE $tbname ( $colDef )"; - $stmt = sqlsrv_prepare($conn, $createSql, array(), $options); - if ($stmt) { - $res = sqlsrv_execute($stmt); - if ($res == false) { - fatalError("createTableEx: failed to execute the query to create table\n"); - } - } else { - fatalError("createTableEx: failed to prepare the statement to create table\n"); - } - return $stmt; -} - /** * Insert a row into a table * @param resource $conn : sqlsrv connection resource @@ -435,7 +405,7 @@ function insertRow($conn, $tbname, $inputs, &$r = null, $api = INSERT_QUERY) $stmt = sqlsrv_prepare($conn, $insertSql); if ($stmt) { $r = sqlsrv_execute($stmt); - } + } break; } } else { @@ -462,6 +432,7 @@ function insertRow($conn, $tbname, $inputs, &$r = null, $api = INSERT_QUERY) $stmt = sqlsrv_query($conn, $insertSql, $params); } } + return $stmt; } @@ -681,7 +652,6 @@ function insertTestRow($conn, $tbname, $index) echo("Invalid row index $index for test data!\n"); return false; } - // get array of input values $inputArray = getInsertArray($index); if (empty($inputArray)) { diff --git a/test/functional/sqlsrv/sqlsrv_buffered.phpt b/test/functional/sqlsrv/sqlsrv_buffered.phpt index ffcdf479..e05267aa 100644 --- a/test/functional/sqlsrv/sqlsrv_buffered.phpt +++ b/test/functional/sqlsrv/sqlsrv_buffered.phpt @@ -19,12 +19,7 @@ function insertOneRow($conn, $tableName) "Field7" => "This is field 7."); $query = AE\getInsertSqlPlaceholders($tableName, $data); - // form the array of parameters - $params = array(); - foreach ($data as $key => $input) { - array_push($params, $input); - } - $stmt = sqlsrv_prepare($conn, $query, $params, array("Scrollable"=>SQLSRV_CURSOR_CLIENT_BUFFERED)); + $stmt = sqlsrv_prepare($conn, $query, array_values($data), array("Scrollable"=>SQLSRV_CURSOR_CLIENT_BUFFERED)); } else { $query = "INSERT INTO $tableName ([Field2], [Field3], [Field4], [Field5], [Field6], [Field7]) VALUES ('This is field 2.', 0x010203, 'This is field 4.', 0x040506, 'This is field 6.', 'This is field 7.' )"; $stmt = sqlsrv_prepare($conn, $query, array(), array("Scrollable"=>SQLSRV_CURSOR_CLIENT_BUFFERED)); @@ -75,7 +70,10 @@ $columns = array(new AE\ColumnMeta('int', 'Id', 'NOT NULL Identity (100,2) PRIMA new AE\ColumnMeta('varchar(max)', 'Field6'), new AE\ColumnMeta('nvarchar(max)', 'Field7')); -AE\createTableEx($conn, $tableName, $columns, array("Scrollable"=>SQLSRV_CURSOR_CLIENT_BUFFERED)); +$stmt = AE\createTable($conn, $tableName, $columns); +if (!$stmt) { + fatalError("Failed to create table for the test\n"); +} $stmt = insertOneRow($conn, $tableName); $f2 = fopen('php://memory', 'a'); diff --git a/test/functional/sqlsrv/sqlsrv_fetch_object_unicode_col_name2.phpt b/test/functional/sqlsrv/sqlsrv_fetch_object_unicode_col_name2.phpt index b11a836c..ce96533d 100644 --- a/test/functional/sqlsrv/sqlsrv_fetch_object_unicode_col_name2.phpt +++ b/test/functional/sqlsrv/sqlsrv_fetch_object_unicode_col_name2.phpt @@ -5,7 +5,7 @@ sqlsrv_fetch_object() into a class with Unicode column name --FILE-- SQLSRV_CURSOR_CLIENT_BUFFERED));