2017-02-01 03:10:37 +01:00
--TEST--
Error checking for failed conversion: VARCHAR value 'null' to data type INT
--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();
if (!$conn) {
fatalError("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
$sql = "CREATE TABLE $tableName (ID INT)";
$stmt = sqlsrv_query($conn, $sql);
// Insert data. Wrong statement
$sql = "INSERT INTO $tableName VALUES (12),('null'),(-15)";
$stmt = sqlsrv_query($conn, $sql);
// Error checking
$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 varchar value 'null' to data type int\.
\[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Conversion failed when converting the varchar value 'null' to data type int\.
2017-09-13 23:45:11 +02:00
\)
2017-10-04 23:22:56 +02:00
Done