From 66fa5885acea087a222adaeff0ff17958a9de438 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Wed, 20 Jan 2021 09:37:47 +0100 Subject: [PATCH] Check that sqlsrv and pdo_sqlsrv PHP extensions actually work Test: sqlsrv, pdo_sqlsrv --- scripts/tests/pdo_sqlsrv | 28 ++++++++++++++++++++++++++++ scripts/tests/sqlsrv | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100755 scripts/tests/pdo_sqlsrv create mode 100755 scripts/tests/sqlsrv diff --git a/scripts/tests/pdo_sqlsrv b/scripts/tests/pdo_sqlsrv new file mode 100755 index 0000000..7eb93f4 --- /dev/null +++ b/scripts/tests/pdo_sqlsrv @@ -0,0 +1,28 @@ +#!/usr/bin/env php +getMessage(), 'This extension requires the Microsoft ODBC Driver for SQL Server') !== false) { + fwrite(STDERR, trim($x->getMessage() . "\n")); + exit(1); + } +} diff --git a/scripts/tests/sqlsrv b/scripts/tests/sqlsrv new file mode 100755 index 0000000..afc53ea --- /dev/null +++ b/scripts/tests/sqlsrv @@ -0,0 +1,39 @@ +#!/usr/bin/env php + 'SqlPassword', + 'ConnectRetryCount' => 0, + 'Database' => 'example', + 'LoginTimeout' => 1, // string for PDO_SQLSRV + 'UID' => 'userName', // not for PDO_SQLSRV + 'PWD' => 'password', + ] +); +$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"); + } + } +}