add helper function for checking error messages
This commit is contained in:
parent
57d7400f2c
commit
294537ecb3
|
@ -57,6 +57,16 @@ function createVariantTable($conn, $tableName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkError($e, $expMsg, $aeExpMsg)
|
||||||
|
{
|
||||||
|
$error = $e->getMessage();
|
||||||
|
if (!isAEConnected()) {
|
||||||
|
if (strpos($error, $expMsg) === false) echo $error;
|
||||||
|
} else {
|
||||||
|
if (strpos($error, $aeExpMsg) === false) echo $error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Connect
|
// Connect
|
||||||
$conn = connect();
|
$conn = connect();
|
||||||
|
@ -71,11 +81,9 @@ try {
|
||||||
dropTable($conn, $tableName);
|
dropTable($conn, $tableName);
|
||||||
unset($conn);
|
unset($conn);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$error = $e->getMessage();
|
$expMsg = "Implicit conversion from data type sql_variant to nvarchar(max) is not allowed. Use the CONVERT function to run this query.";
|
||||||
if (!(!isAEConnected() && strpos($error, "Implicit conversion from data type sql_variant to nvarchar(max) is not allowed. Use the CONVERT function to run this query.") !== false) &&
|
$aeExpMsg = "Invalid Descriptor Index";
|
||||||
!(isAEConnected() && strpos($error, "Invalid Descriptor Index") !== false)) {
|
checkError($e, $expMsg, $aeExpMsg);
|
||||||
echo $error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
echo "Done\n";
|
echo "Done\n";
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,10 @@ try {
|
||||||
print_r("Prepare with emulate prepare and and SQLSRV_ENCODING_SYSTEM:\n");
|
print_r("Prepare with emulate prepare and and SQLSRV_ENCODING_SYSTEM:\n");
|
||||||
$stmt = prepareStmt($conn, $query, $options, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_SYSTEM);
|
$stmt = prepareStmt($conn, $query, $options, PDO::PARAM_STR, 0, PDO::SQLSRV_ENCODING_SYSTEM);
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
// Linux supports binding UTF8 data with SQLSRV_ENCODING_SYSTEM since the default encoding in Linux is UTF8
|
|
||||||
|
// The combination of Column Encryption and Unix platforms support SQLSRV_ENCODING_SYSTEM because:
|
||||||
|
// With Column Encryption enabled, binding parameters uses exact datatypes as the column definition
|
||||||
|
// the default encoding in Linux and Mac is UTF8
|
||||||
$success = true;
|
$success = true;
|
||||||
if (!(strtoupper( substr( php_uname( 's' ),0,3 ) ) === 'WIN') && isAEConnected()) {
|
if (!(strtoupper( substr( php_uname( 's' ),0,3 ) ) === 'WIN') && isAEConnected()) {
|
||||||
if ($row['name'] != "가각" || $row['status'] != 1 || $row['age'] != 30) {
|
if ($row['name'] != "가각" || $row['status'] != 1 || $row['age'] != 30) {
|
||||||
|
@ -78,6 +81,7 @@ try {
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// the default encoding in Windows is non-UTF8, thus binding UTF8 parameters does not work
|
||||||
if ($stmt->rowCount() != 0) {
|
if ($stmt->rowCount() != 0) {
|
||||||
print_r("Binding UTF8 data when encoding is SQLSRV_ENCODING_SYSTEM should not work.\n");
|
print_r("Binding UTF8 data when encoding is SQLSRV_ENCODING_SYSTEM should not work.\n");
|
||||||
$success = false;
|
$success = false;
|
||||||
|
|
|
@ -6,6 +6,16 @@ Test UTF8 Encoding with emulate prepare
|
||||||
<?php
|
<?php
|
||||||
require_once("MsCommon_mid-refactor.inc");
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
|
||||||
|
function checkError($e, $expMsg, $aeExpMsg)
|
||||||
|
{
|
||||||
|
$error = $e->getMessage();
|
||||||
|
if (!isAEConnected()) {
|
||||||
|
if (strpos($error, $expMsg) === false) echo $error;
|
||||||
|
} else {
|
||||||
|
if (strpos($error, $aeExpMsg) === false) echo $error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$inValue1 = pack('H*', '3C586D6C54657374446174613E4A65207072C3A966C3A87265206C27C3A974C3A93C2F586D6C54657374446174613E');
|
$inValue1 = pack('H*', '3C586D6C54657374446174613E4A65207072C3A966C3A87265206C27C3A974C3A93C2F586D6C54657374446174613E');
|
||||||
$inValueLen = strlen($inValue1);
|
$inValueLen = strlen($inValue1);
|
||||||
|
@ -72,11 +82,9 @@ try {
|
||||||
dropTable($conn, $tbname);
|
dropTable($conn, $tbname);
|
||||||
unset($conn);
|
unset($conn);
|
||||||
} catch (PDOexception $e) {
|
} catch (PDOexception $e) {
|
||||||
$error = $e->getMessage();
|
$expMsg = "Statement with emulate prepare on does not support output or input_output parameters.";
|
||||||
if (!(!isAEConnected() && strpos($error, "Statement with emulate prepare on does not support output or input_output parameters.") !== false) &&
|
$aeExpMsg = "Invalid Descriptor Index";
|
||||||
!(isAEConnected() && strpos($error, "Invalid Descriptor Index") !== false)) {
|
checkError($e, $expMsg, $aeExpMsg);
|
||||||
echo $error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
|
Loading…
Reference in a new issue