2017-03-31 01:30:54 +02:00
|
|
|
|
--TEST--
|
2017-04-06 00:07:18 +02:00
|
|
|
|
Populate different unicode character fields using null stream data as inputs
|
2017-11-29 01:40:49 +01:00
|
|
|
|
--SKIPIF--
|
|
|
|
|
<?php require('skipif_versions_old.inc'); ?>
|
2017-03-31 01:30:54 +02:00
|
|
|
|
--FILE--
|
|
|
|
|
<?php
|
2017-10-04 23:22:56 +02:00
|
|
|
|
require_once('MsCommon.inc');
|
2017-03-31 01:30:54 +02:00
|
|
|
|
|
2017-11-29 01:40:49 +01:00
|
|
|
|
function char2Stream($conn)
|
2017-03-31 01:30:54 +02:00
|
|
|
|
{
|
2017-11-29 01:40:49 +01:00
|
|
|
|
$tableName = 'streams_null_nchar';
|
2017-10-04 23:22:56 +02:00
|
|
|
|
|
|
|
|
|
// create a test table
|
2017-11-29 01:40:49 +01:00
|
|
|
|
$columns = array(new AE\ColumnMeta('int', 'c1_int'),
|
|
|
|
|
new AE\ColumnMeta('nchar(512)', 'c2_nchar'),
|
|
|
|
|
new AE\ColumnMeta('nvarchar(512)', 'c3_nvarchar'),
|
|
|
|
|
new AE\ColumnMeta('nvarchar(max)', 'c4_nvarchar_max'),
|
|
|
|
|
new AE\ColumnMeta('ntext', 'c5_ntext'));
|
|
|
|
|
$stmt = AE\createTable($conn, $tableName, $columns);
|
|
|
|
|
if (!$stmt) {
|
|
|
|
|
fatalError("Failed to create table $tableName\n");
|
|
|
|
|
}
|
2017-03-31 01:30:54 +02:00
|
|
|
|
sqlsrv_free_stmt($stmt);
|
|
|
|
|
|
|
|
|
|
$fname = null;
|
2017-11-29 01:40:49 +01:00
|
|
|
|
$query = "INSERT INTO $tableName (c1_int, c2_nchar, c3_nvarchar, c4_nvarchar_max, c5_ntext) VALUES (?, ?, ?, ?, ?)";
|
|
|
|
|
$res = true;
|
|
|
|
|
if (AE\isColEncrypted()) {
|
|
|
|
|
$stmt = sqlsrv_prepare($conn, $query, array(-187518515, &$fname, &$fname, &$fname, &$fname));
|
|
|
|
|
if ($stmt) {
|
|
|
|
|
$res = sqlsrv_execute($stmt);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$stmt = sqlsrv_query($conn, $query, array(-187518515, &$fname, &$fname, &$fname, &$fname));
|
|
|
|
|
}
|
|
|
|
|
if ($stmt === false || !$res) {
|
|
|
|
|
fatalError("Failed in sendQueryStream for $value\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sqlsrv_send_stream_data($stmt);
|
2017-03-31 01:30:54 +02:00
|
|
|
|
sqlsrv_free_stmt($stmt);
|
2017-10-04 23:22:56 +02:00
|
|
|
|
|
2017-11-29 01:40:49 +01:00
|
|
|
|
fetchData($conn, $tableName);
|
|
|
|
|
dropTable($conn, $tableName);
|
2017-03-31 01:30:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-29 01:40:49 +01:00
|
|
|
|
function fetchData($conn, $tableName)
|
2017-03-31 01:30:54 +02:00
|
|
|
|
{
|
|
|
|
|
$stmt = sqlsrv_prepare($conn, "SELECT * FROM $tableName");
|
|
|
|
|
sqlsrv_execute($stmt);
|
|
|
|
|
$result = sqlsrv_fetch($stmt);
|
2017-04-06 00:07:18 +02:00
|
|
|
|
$numfields = sqlsrv_num_fields($stmt);
|
2017-10-04 23:22:56 +02:00
|
|
|
|
for ($i = 1; $i < $numfields; $i++) {
|
2017-04-06 00:07:18 +02:00
|
|
|
|
$value = sqlsrv_get_field($stmt, $i, SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_BINARY));
|
2017-10-04 23:22:56 +02:00
|
|
|
|
var_dump($value);
|
2017-04-06 00:07:18 +02:00
|
|
|
|
}
|
2017-03-31 01:30:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-29 01:40:49 +01:00
|
|
|
|
echo "\nTest begins...\n";
|
|
|
|
|
try {
|
|
|
|
|
set_time_limit(0);
|
|
|
|
|
sqlsrv_configure('WarningsReturnAsErrors', 1);
|
2017-10-04 23:22:56 +02:00
|
|
|
|
|
2017-11-29 01:40:49 +01:00
|
|
|
|
// connect
|
|
|
|
|
$conn = AE\connect();
|
2017-03-31 01:30:54 +02:00
|
|
|
|
|
2017-11-29 01:40:49 +01:00
|
|
|
|
char2Stream($conn);
|
2017-03-31 01:30:54 +02:00
|
|
|
|
|
2017-11-29 01:40:49 +01:00
|
|
|
|
sqlsrv_close($conn);
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
echo $e->getMessage();
|
2017-03-31 01:30:54 +02:00
|
|
|
|
}
|
2017-11-29 01:40:49 +01:00
|
|
|
|
echo "\nDone\n";
|
2017-03-31 01:30:54 +02:00
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
--EXPECT--
|
|
|
|
|
|
2017-05-02 02:01:30 +02:00
|
|
|
|
Test begins...
|
2017-03-31 01:30:54 +02:00
|
|
|
|
NULL
|
|
|
|
|
NULL
|
|
|
|
|
NULL
|
|
|
|
|
NULL
|
|
|
|
|
|
|
|
|
|
Done
|