2017-09-14 02:46:44 +02:00
--TEST--
2017-09-15 00:04:55 +02:00
Test for inserting and retrieving encrypted data of string types
2017-09-26 01:37:27 +02:00
--DESCRIPTION--
2017-09-14 02:46:44 +02:00
Bind params using sqlsrv_prepare without any sql_type specified
--SKIPIF--
2017-09-14 18:47:40 +02:00
<?php require('skipif_versions_old.inc'); ?>
2017-09-14 02:46:44 +02:00
--FILE--
<?php
2017-10-04 23:22:56 +02:00
require_once('MsCommon.inc');
require_once('AEData.inc');
2017-09-14 02:46:44 +02:00
$dataTypes = array( "char(5)", "varchar(max)", "nchar(5)", "nvarchar(max)" );
2017-10-04 23:22:56 +02:00
$conn = AE\connect();
2017-09-14 02:46:44 +02:00
2017-10-04 23:22:56 +02:00
foreach ($dataTypes as $dataType) {
2017-09-14 02:46:44 +02:00
echo "\nTesting $dataType: \n";
2017-10-04 23:22:56 +02:00
2017-09-14 02:46:44 +02:00
// create table
2017-10-04 23:22:56 +02:00
$tbname = GetTempTableName("", false);
2017-10-05 01:51:15 +02:00
$colMetaArr = array( new AE\ColumnMeta($dataType, "c_det"), new AE\ColumnMeta($dataType, "c_rand", null, false));
2017-10-04 23:22:56 +02:00
AE\createTable($conn, $tbname, $colMetaArr);
2017-09-14 02:46:44 +02:00
// insert a row
2017-10-04 23:22:56 +02:00
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
2017-09-14 02:46:44 +02:00
$r;
2017-10-04 23:22:56 +02:00
$stmt = AE\insertRow($conn, $tbname, array( $colMetaArr[0]->colName => $inputValues[0], $colMetaArr[1]->colName => $inputValues[1] ), $r);
if ($r === false) {
is_incompatible_types_error($dataType, "default type");
} else {
2017-09-14 02:46:44 +02:00
echo "****Encrypted default type is compatible with encrypted $dataType****\n";
2017-10-04 23:22:56 +02:00
AE\fetchAll($conn, $tbname);
2017-09-14 02:46:44 +02:00
}
2017-10-04 23:22:56 +02:00
dropTable($conn, $tbname);
2017-09-14 02:46:44 +02:00
}
2017-10-04 23:22:56 +02:00
sqlsrv_free_stmt($stmt);
sqlsrv_close($conn);
2017-09-14 02:46:44 +02:00
?>
--EXPECT--
2017-09-14 20:40:13 +02:00
Testing char(5):
2017-09-14 02:46:44 +02:00
****Encrypted default type is compatible with encrypted char(5)****
c_det: -leng
c_rand: th, n
2017-09-14 20:40:13 +02:00
Testing varchar(max):
2017-09-14 02:46:44 +02:00
****Encrypted default type is compatible with encrypted varchar(max)****
c_det: Use varchar(max) when the sizes of the column data entries vary considerably, and the size might exceed 8,000 bytes.
c_rand: Each non-null varchar(max) or nvarchar(max) column requires 24 bytes of additional fixed allocation which counts against the 8,060 byte row limit during a sort operation.
2017-09-14 20:40:13 +02:00
Testing nchar(5):
2017-09-14 02:46:44 +02:00
****Encrypted default type is compatible with encrypted nchar(5)****
c_det: -leng
c_rand: th Un
2017-09-14 20:40:13 +02:00
Testing nvarchar(max):
2017-09-14 02:46:44 +02:00
****Encrypted default type is compatible with encrypted nvarchar(max)****
c_det: When prefixing a string constant with the letter N, the implicit conversion will result in a Unicode string if the constant to convert does not exceed the max length for a Unicode string data type (4,000).
2017-09-26 01:37:27 +02:00
c_rand: Otherwise, the implicit conversion will result in a Unicode large-value (max).