fatalError("Failed when preparing to call $storedProcName");
}
$result = sqlsrv_execute($stmt);
if ($dateAsString) {
// Expect to succeed when returning a DateTime value as a string
// The output param value should be the same as the input value
if (!$result) {
fatalError("Failed when invoking $storedProcName");
}
if ($outDateStr != $inputValue) {
echo "Expected $inputValue but got $outDateStr\n";
}
} else {
// Expect to fail with an error message because setting a DateTime object as the
// output parameter is not allowed
if ($result) {
fatalError("Returning DateTime as output param is expected to fail!");
}
// Check if the error message is the expected one
$error = sqlsrv_errors()[0]['message'];
$message = 'An invalid PHP type was specified as an output parameter. DateTime objects, NULL values, and streams cannot be specified as output parameters';
if (strpos($error, $message) === false) {
print_r(sqlsrv_errors());
}
}
}
set_time_limit(0);
sqlsrv_configure('WarningsReturnAsErrors', 1);
date_default_timezone_set('America/Los_Angeles');
// Connect with ReturnDatesAsStrings option set to true