docker-php-extension-installer/scripts/tests/sqlsrv

43 lines
1.0 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env php
<?php
error_reporting(-1);
set_error_handler(
static function ($errno, $errstr, $errfile, $errline) {
$msg = "Error {$errno}: {$errstr}\n";
if ($errfile) {
$msg .= "File: {$errfile}\n";
if ($errline) {
$msg .= "Line: {$errline}\n";
}
}
fwrite(STDERR, $msg);
exit(1);
},
-1
);
sqlsrv_connect(
'localhost, 50000',
[
'Authentication' => 'SqlPassword',
'ConnectRetryCount' => 0,
'Database' => 'example',
'LoginTimeout' => 1, // string for PDO_SQLSRV
'UID' => 'userName', // not for PDO_SQLSRV
'PWD' => 'password',
]
);
2021-08-26 07:24:53 +00:00
$rc = 0;
$errors = sqlsrv_errors(SQLSRV_ERR_ALL);
if (is_array($errors)) {
foreach ($errors as $error) {
if (isset($error['message']) && stripos($error['message'], 'This extension requires the Microsoft ODBC Driver for SQL Server') !== false) {
fwrite(STDERR, trim($error['message']) . "\n");
2021-08-26 07:24:53 +00:00
$rc = 1;
}
}
}
2021-08-26 07:24:53 +00:00
exit($rc);