Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**This is included from unit tests to skip the test if MDB2 is not available.
3
*
4
* LICENSE:
5
* This source file is subject to version 2.1 of the LGPL
6
* that is bundled with this package in the file LICENSE.
7
*
8
* COPYRIGHT:
9
* Empowered Media
10
* http://www.empoweredmedia.com
11
* 481 Eighth Avenue Suite 1530
12
* New York, NY 10001
13
*
14
* @copyright Empowered Media 2006
15
* @license http://www.gnu.org/copyleft/lesser.html  LGPL Version 2.1
16
* @author Lukas Feiler <lukas.feiler@lukasfeiler.com>
17
* @package XML_Query2XML
18
* @version $Id: PDO_skipif.php 302587 2010-08-20 23:53:59Z clockwerx $
19
*/
20
 
21
if (!class_exists('PDO')) {
22
    print 'skip could not find PDO';
23
    exit;
24
} else {
25
    require_once dirname(dirname(__FILE__)) . '/settings.php';
26
 
27
    list($protocol, $address) = explode('://', DSN);
28
    if (strpos($address, '@') === false) {
29
        if ($protocol == 'sqlite') {
30
            $protocol .= '2';
31
        }
32
        if (strpos($address, '/C:\\') === 0) {
33
            $address = ltrim($address, '/');
34
        }
35
        try {
36
            $db = new PDO($protocol . ':' . $address);
37
        } catch (PDOException $e) {
38
            print 'skip could not connect using DSN ' . DSN . ': ' . $e->getMessage();
39
            exit;
40
        }
41
    } else {
42
        list($credentials, $address) = explode('@', $address);
43
            if (strpos($credentials, ':') === false) {
44
            $username = $credentials;
45
            $password = '';
46
        } else {
47
            list($username, $password) = explode(':', $credentials);
48
        }
49
        list($host,$database) = explode('/', $address);
50
        try {
51
            $db = new PDO($protocol . ':host=' . $host . ';dbname=' . $database, $username, $password);
52
        } catch (PDOException $e) {
53
            print 'skip could not connect using DSN ' . DSN . ': ' . $e->getMessage();
54
            exit;
55
        }
56
    }
57
}
58
?>