xref: /php-src/ext/dba/tests/dba_db4_018.phpt (revision eddab740)
1--TEST--
2DBA DB4 with persistent connections
3--EXTENSIONS--
4dba
5--CONFLICTS--
6dba
7--SKIPIF--
8<?php
9$handler = "db4";
10require_once(__DIR__ .'/skipif.inc');
11die("info $HND handler used");
12?>
13--FILE--
14<?php
15
16$handler = "db4";
17require_once(__DIR__ .'/test.inc');
18echo "database handler: $handler\n";
19
20echo "Test 1\n";
21$db_file1 = dba_popen($db_filename, 'n', 'flatfile');
22dba_insert("key1", "This is a test insert 1", $db_file1);
23echo dba_fetch("key1", $db_file1), "\n";
24
25
26echo "Test 2\n";
27$db_file2 = dba_popen($db_filename, 'n', 'flatfile');
28if ($db_file1 === $db_file2) {
29    echo "resources are the same\n";
30} else {
31    echo "resources are different\n";
32}
33
34
35echo "Test 3 - fetch both rows from second resource\n";
36dba_insert("key2", "This is a test insert 2", $db_file2);
37echo dba_fetch("key1", $db_file2), "\n";
38echo dba_fetch("key2", $db_file2), "\n";
39
40
41echo "Test 4 - fetch both rows from first resource\n";
42echo dba_fetch("key1", $db_file1), "\n";
43echo dba_fetch("key2", $db_file1), "\n";
44
45echo "Test 5 - close 2nd resource\n";
46dba_close($db_file2);
47var_dump($db_file1);
48var_dump($db_file2);
49
50echo "Test 6 - query after closing 2nd resource\n";
51echo dba_fetch("key1", $db_file1), "\n";
52echo dba_fetch("key2", $db_file1), "\n";
53
54?>
55--CLEAN--
56<?php
57    require(__DIR__ .'/clean.inc');
58?>
59--EXPECTF--
60database handler: db4
61Test 1
62This is a test insert 1
63Test 2
64resources are different
65Test 3 - fetch both rows from second resource
66This is a test insert 1
67This is a test insert 2
68Test 4 - fetch both rows from first resource
69This is a test insert 1
70This is a test insert 2
71Test 5 - close 2nd resource
72resource(%d) of type (dba persistent)
73resource(%d) of type (Unknown)
74Test 6 - query after closing 2nd resource
75This is a test insert 1
76This is a test insert 2
77