xref: /PHP-8.3/ext/pdo_dblib/tests/config.inc (revision e295266f)
1<?php
2
3// bug #72969 reflects a bug with FreeTDS, not with pdo_dblib
4// this function will version detect so the relevant tests can XFAILIF
5// assume this bug isn't present if not using FreeTDS
6// otherwise require FreeTDS>=1.1
7function driver_supports_batch_statements_without_select($db) {
8    $version = $db->getAttribute(PDO::DBLIB_ATTR_VERSION);
9    return !strstartswith($version, 'freetds ') || !strstartswith($version, 'freetds v1.0');
10}
11
12function strstartswith($haystack, $needle) {
13    return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false;
14}
15
16if (false !== getenv('PDO_DBLIB_TEST_DSN')) {
17    $dsn = getenv('PDO_DBLIB_TEST_DSN');
18} else {
19    $dsn = 'dblib:host=localhost;dbname=test';
20}
21
22if (false !== getenv('PDO_DBLIB_TEST_USER')) {
23    $user = getenv('PDO_DBLIB_TEST_USER');
24} else {
25    $user = 'php';
26}
27
28if (false !== getenv('PDO_DBLIB_TEST_PASS')) {
29    $pass = getenv('PDO_DBLIB_TEST_PASS');
30} else {
31    $pass = 'password';
32}
33
34try {
35    $db = new PDO($dsn, $user, $pass);
36    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
37    $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
38} catch (PDOException $e) {
39    die('skip ' . $e->getMessage());
40}
41
42?>
43