php-sqlsrv/test/functional/pdo_sqlsrv/skipif_version_less_than_2k16.inc
Jenny Tam e51380612d
Adding supporting for Azure AD access token (#837)
* Adding supporting for Azure AD access token

* Added more comments for the AD access token skipif files

* Save the pointer to access token struct until after connecting

* Clear the access token data before freeing the memory

* Added a reference as per review
2018-09-06 11:32:04 -07:00

46 lines
1.2 KiB
PHP

<?php
// For Azure ActiveDirectory, must check that
// 1. Either running Windows, or ODBC driver 17 or greater on unix
// 2. Either SQL Server version is 2016 or greater, or using Azure
if (!extension_loaded("pdo_sqlsrv")) {
die("skip Extension not loaded");
}
$is_win = (strtoupper(substr(php_uname('s'),0,3)) === 'WIN');
require_once("MsSetup.inc");
$conn = new PDO("sqlsrv:server = $server; driver=$driver;", $uid, $pwd);
if ($conn === false) {
die( "skip Could not connect during SKIPIF." );
}
$msodbcsql_ver = $conn->getAttribute(PDO::ATTR_CLIENT_VERSION)["DriverVer"];
$msodbcsql_maj = explode(".", $msodbcsql_ver)[0];
$msodbcsql_min = explode(".", $msodbcsql_ver)[1];
if (!$is_win) {
if ($msodbcsql_maj < 17) {
die("skip Unsupported ODBC driver version");
}
}
// Get SQL Server Version
// Exclude this check if running on Azure
if (!$daasMode) {
$stmt = $conn->query( "SELECT @@VERSION" );
if ($stmt) {
$ver_string = $stmt->fetch(PDO::FETCH_NUM)[0];
} else {
die( "skip Could not fetch SQL Server version during SKIPIF.");
}
$version = explode(' ', $ver_string);
if ($version[3] < '2016') {
die("skip Wrong version of SQL Server, 2016 or later required");
}
}
?>