xref: /PHP-8.1/ext/dba/tests/dba_db4_018.phpt (revision b5a14e6c)
1--TEST--
2DBA DB4 with persistent connections
3--EXTENSIONS--
4dba
5--SKIPIF--
6<?php
7$handler = "db4";
8require_once(__DIR__ .'/skipif.inc');
9die("info $HND handler used");
10?>
11--FILE--
12<?php
13
14$handler = "db4";
15require_once(__DIR__ .'/test.inc');
16echo "database handler: $handler\n";
17
18echo "Test 1\n";
19$db_file1 = dba_popen($db_filename, 'n', 'flatfile');
20dba_insert("key1", "This is a test insert 1", $db_file1);
21echo dba_fetch("key1", $db_file1), "\n";
22
23
24echo "Test 2\n";
25$db_file2 = dba_popen($db_filename, 'n', 'flatfile');
26if ($db_file1 === $db_file2) {
27    echo "resources are the same\n";
28} else {
29    echo "resources are different\n";
30}
31
32
33echo "Test 3 - fetch both rows from second resource\n";
34dba_insert("key2", "This is a test insert 2", $db_file2);
35echo dba_fetch("key1", $db_file2), "\n";
36echo dba_fetch("key2", $db_file2), "\n";
37
38
39echo "Test 4 - fetch both rows from first resource\n";
40echo dba_fetch("key1", $db_file1), "\n";
41echo dba_fetch("key2", $db_file1), "\n";
42
43echo "Test 5 - close 2nd resource\n";
44dba_close($db_file2);
45var_dump($db_file1);
46var_dump($db_file2);
47
48echo "Test 6 - query after closing 2nd resource\n";
49echo dba_fetch("key1", $db_file1), "\n";
50echo dba_fetch("key2", $db_file1), "\n";
51
52?>
53--CLEAN--
54<?php
55    require(__DIR__ .'/clean.inc');
56?>
57--XFAIL--
58Test 6 crashes with dba pointer of NULL, bug http://bugs.php.net/bug.php?id=51278
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