2017-02-01 03:10:37 +01:00
--TEST--
Error checking for failed explicit data type conversions NCHAR(2)
--SKIPIF--
--FILE--
<?php
2017-05-02 02:01:30 +02:00
require_once("MsCommon.inc");
2017-02-01 03:10:37 +01:00
2017-10-04 23:22:56 +02:00
// connect
$conn = connect(array("CharacterSet"=>"utf-8"));
if (!$conn) {
printErrors("Connection could not be established.\n");
2017-05-02 02:01:30 +02:00
}
2017-02-01 03:10:37 +01:00
2017-05-02 02:01:30 +02:00
$tableName = GetTempTableName();
2017-02-01 03:10:37 +01:00
// Create table. Column names: passport
$sql = "CREATE TABLE $tableName (c1 NCHAR(2))";
$stmt = sqlsrv_query($conn, $sql);
// Insert data. Invalid statement
$sql = "INSERT INTO $tableName VALUES (10),(N'银河')";
$stmt = sqlsrv_query($conn, $sql);
// Get extended error
$err = sqlsrv_errors();
print_r($err[0]);
// Free statement and connection resources
sqlsrv_close($conn);
print "Done"
?>
2017-09-13 23:45:11 +02:00
--EXPECTREGEX--
2017-02-01 03:10:37 +01:00
Array
2017-09-13 23:45:11 +02:00
\(
\[0\] => 22018
\[SQLSTATE\] => 22018
\[1\] => 245
\[code\] => 245
2017-09-14 01:50:42 +02:00
\[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Conversion failed when converting the nvarchar value '银河' to data type int\.
\[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Conversion failed when converting the nvarchar value '银河' to data type int\.
2017-09-13 23:45:11 +02:00
\)
2017-02-01 03:10:37 +01:00
Done