summaryrefslogtreecommitdiff
path: root/ext/pdo_dblib/tests/config.inc
blob: 346de0f8ca730e7b217a070ebe3cb696d719d45a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php

function get_tds_version() {
	global $dsn;

	$dsn_parts = explode(':', $dsn, 2);
	if ($dsn_parts[0] == 'dblib') { // uri is an option, which we'll ignore
		foreach (explode(';', $dsn_parts[1]) as $arg) {
			$arg = explode('=', $arg);
			if ($arg[0] == 'version') {
				return $arg[1];
			}
		}
	}

	return null;
}

if (false !== getenv('PDO_DBLIB_TEST_DSN')) 
	$dsn = getenv('PDO_DBLIB_TEST_DSN');
else
	$dsn = 'dblib:host=localhost;dbname=test';

if (false !== getenv('PDO_DBLIB_TEST_USER')) 	
	$user = getenv('PDO_DBLIB_TEST_USER');
else
	$user = 'php';
	
	
if (false !== getenv('PDO_DBLIB_TEST_PASS')) 	
	$pass = getenv('PDO_DBLIB_TEST_PASS');
else
	$pass = 'password';

try {
	$db = new PDO($dsn, $user, $pass);
	$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
	$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
} catch (PDOException $e) {
	die('skip ' . $e->getMessage());
}
?>