xref: /PHP-8.2/ext/dba/tests/dba015.phpt (revision eddab740)
1--TEST--
2DBA with persistent connections
3--EXTENSIONS--
4dba
5--SKIPIF--
6<?php
7$handler = "flatfile";
8require_once(__DIR__ .'/skipif.inc');
9die("info $HND handler used");
10?>
11--CONFLICTS--
12dba
13--FILE--
14<?php
15
16$handler = "flatfile";
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: flatfile
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