php-sqlsrv/test/functional/pdo_sqlsrv/pdo_033_binary_unicode.phpt

49 lines
1.1 KiB
Plaintext
Raw Normal View History

2017-06-05 18:26:02 +02:00
--TEST--
Insert binary HEX data then fetch it back as string
--DESCRIPTION--
2017-10-11 00:56:41 +02:00
Insert binary HEX data into an nvarchar field then read it back as UTF-8 string
2017-06-05 18:26:02 +02:00
--SKIPIF--
<?php require('skipif_mid-refactor.inc'); ?>
2017-06-05 18:26:02 +02:00
--FILE--
<?php
require_once("MsCommon_mid-refactor.inc");
2017-06-05 18:26:02 +02:00
try {
2017-06-05 18:26:02 +02:00
// Connect
$conn = connect();
2017-06-05 18:26:02 +02:00
// Create table
$tableName = 'pdo_033test';
createTable($conn, $tableName, array("c1" => "nvarchar(100)"));
2017-06-05 18:26:02 +02:00
2017-10-11 00:56:41 +02:00
$input = pack("H*", '49006427500048005000'); // I'LOVE_SYMBOL'PHP
$result;
$stmt = insertRow($conn, $tableName, array("c1" => new BindParamOp(1, $input, "PDO::PARAM_STR", 0, "PDO::SQLSRV_ENCODING_BINARY")), "prepareBindParam", $result);
2017-10-11 00:56:41 +02:00
2017-10-10 20:34:59 +02:00
if (!$result) {
2017-06-05 18:26:02 +02:00
echo "Failed to insert!\n";
2017-10-11 00:56:41 +02:00
dropTable($conn, $tableName);
unset($stmt);
unset($conn);
2017-10-10 20:34:59 +02:00
exit;
}
2017-06-05 18:26:02 +02:00
$stmt = $conn->query("SELECT * FROM $tableName");
$utf8 = $stmt->fetchColumn();
echo "$utf8\n";
2017-06-05 18:26:02 +02:00
dropTable($conn, $tableName);
unset($stmt);
unset($conn);
} catch (PDOException $e) {
var_dump($e->errorInfo);
2017-06-05 18:26:02 +02:00
}
2017-10-11 00:56:41 +02:00
2017-06-05 18:26:02 +02:00
print "Done";
?>
--EXPECT--
I❤PHP
2017-10-11 00:56:41 +02:00
Done