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 chdir(dirname(__FILE__)); require_once './skipif.inc'; ?>
7
--FILE--
8
<?php
9
require_once './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
        default:
42
            if (gettype($dbh->connection) == 'resource') {
43
                print "$name is connected\n";
44
            } else {
45
                print "$name NOT connected\n";
46
            }
47
    }
48
}
49
 
50
 
51
check_dbh($dbh, '$dbh');
52
 
53
 
54
$test_array_dsn = DB::parseDSN($dsn);
55
foreach ($test_array_dsn as $key => $value) {
56
    if ($value === false) {
57
        unset($test_array_dsn[$key]);
58
    }
59
}
60
 
61
$dbha =& DB::connect($test_array_dsn, $options);
62
check_dbh($dbha, '$dbha');
63
 
64
 
65
$tmp  = serialize($dbha);
66
$dbhu = unserialize($tmp);
67
check_dbh($dbhu, '$dbhu');
68
 
69
?>
70
--EXPECT--
71
$dbh is an object
72
$dbh is connected
73
$dbha is an object
74
$dbha is connected
75
$dbhu is an object
76
$dbhu is connected