xref: /PHP-7.0/ext/pdo_dblib/tests/config.inc (revision 91c49c4a)
1<?php
2
3function get_tds_version() {
4	global $dsn;
5
6	$dsn_parts = explode(':', $dsn, 2);
7	if ($dsn_parts[0] == 'dblib') { // uri is an option, which we'll ignore
8		foreach (explode(';', $dsn_parts[1]) as $arg) {
9			$arg = explode('=', $arg);
10			if ($arg[0] == 'version') {
11				return $arg[1];
12			}
13		}
14	}
15
16	return null;
17}
18
19if (false !== getenv('PDO_DBLIB_TEST_DSN'))
20	$dsn = getenv('PDO_DBLIB_TEST_DSN');
21else
22	$dsn = 'dblib:host=localhost;dbname=test';
23
24if (false !== getenv('PDO_DBLIB_TEST_USER'))
25	$user = getenv('PDO_DBLIB_TEST_USER');
26else
27	$user = 'php';
28
29
30if (false !== getenv('PDO_DBLIB_TEST_PASS'))
31	$pass = getenv('PDO_DBLIB_TEST_PASS');
32else
33	$pass = 'password';
34
35try {
36	$db = new PDO($dsn, $user, $pass);
37	$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
38	$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
39} catch (PDOException $e) {
40	die('skip ' . $e->getMessage());
41}
42?>
43