xref: /php-src/ext/dba/tests/dba015.phpt (revision 8a201545)
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 "objects are the same\n";
30} else {
31    echo "objects are different\n";
32}
33
34
35echo "Test 3 - fetch both rows from second object\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 object\n";
42echo dba_fetch("key1", $db_file1), "\n";
43echo dba_fetch("key2", $db_file1), "\n";
44
45echo "Test 5 - close 2nd object\n";
46dba_close($db_file2);
47var_dump($db_file1);
48try {
49    dba_exists("key1", $db_file2);
50} catch (Error $e) {
51    echo $e->getMessage() . "\n";
52}
53
54echo "Test 6 - query after closing 2nd object\n";
55echo dba_fetch("key1", $db_file1), "\n";
56echo dba_fetch("key2", $db_file1), "\n";
57
58?>
59--CLEAN--
60<?php
61    require(__DIR__ .'/clean.inc');
62?>
63--EXPECTF--
64database handler: flatfile
65Test 1
66This is a test insert 1
67Test 2
68objects are different
69Test 3 - fetch both rows from second object
70This is a test insert 1
71This is a test insert 2
72Test 4 - fetch both rows from first object
73This is a test insert 1
74This is a test insert 2
75Test 5 - close 2nd object
76object(Dba\Connection)#%d (%d) {
77}
78DBA connection has already been closed
79Test 6 - query after closing 2nd object
80This is a test insert 1
81This is a test insert 2
82