Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
--TEST--
2
DB_driver::connect
3
--INI--
4
error_reporting = 2047
5
--SKIPIF--
6
<?php require_once dirname(__FILE__) . '/skipif.inc'; ?>
7
--FILE--
8
<?php
9
require_once dirname(__FILE__) . '/connect.inc';
10
 
11
/**
12
 * Determine if the database connection matches what's expected
13
 *
14
 * @param object $dbh   the PEAR DB object
15
 * @param string $name  the name of the current test
16
 *
17
 * @return void
18
 */
19
function check_dbh($dbh, $name) {
20
    if (DB::isError($dbh)) {
21
        die('connect.inc: ' . $dbh->toString());
22
    }
23
    if (is_object($dbh)) {
24
        print "$name is an object\n";
25
    }
26
    switch ($dbh->phptype) {
27
        case 'dbase':
28
            if (is_int($dbh->connection)) {
29
                print "$name is connected\n";
30
            } else {
31
                print "$name NOT connected\n";
32
            }
33
            break;
34
        case 'mysqli':
35
            if (is_a($dbh->connection, 'mysqli')) {
36
                print "$name is connected\n";
37
            } else {
38
                print "$name NOT connected\n";
39
            }
40
            break;
41
        case 'sybase':
42
            if (gettype($dbh->connection) == 'resource' ||
43
                (gettype($dbh->connection) == 'integer' && $dbh->connection > 0)) {
44
                print "$name is connected\n";
45
            } else {
46
                print "$name NOT connected\n";
47
            }
48
            break;
49
        default:
50
            if (gettype($dbh->connection) == 'resource') {
51
                print "$name is connected\n";
52
            } else {
53
                print "$name NOT connected\n";
54
            }
55
    }
56
}
57
 
58
 
59
check_dbh($dbh, '$dbh');
60
 
61
 
62
$test_array_dsn = DB::parseDSN($dsn);
63
foreach ($test_array_dsn as $key => $value) {
64
    if ($value === false) {
65
        unset($test_array_dsn[$key]);
66
    }
67
}
68
 
69
$dbha =& DB::connect($test_array_dsn, $options);
70
check_dbh($dbha, '$dbha');
71
 
72
 
73
$tmp  = serialize($dbha);
74
$dbhu = unserialize($tmp);
75
check_dbh($dbhu, '$dbhu');
76
 
77
?>
78
--EXPECT--
79
$dbh is an object
80
$dbh is connected
81
$dbha is an object
82
$dbha is connected
83
$dbhu is an object
84
$dbhu is connected