3 // Open a new Db4Env. By default it is transactional. The directory
4 // path in the open() call must exist.
6 $dbenv->set_data_dir("/var/tmp/dbhome");
7 $dbenv->open("/var/tmp/dbhome");
9 // Open a database in $dbenv.
10 $db = new Db4($dbenv);
11 $txn = $dbenv->txn_begin();
12 $db->open($txn, 'a', 'foo');
15 $counter = $db->get("counter");
16 // Create a new transaction
17 $txn = $dbenv->txn_begin();
19 print "txn_begin failed";
22 print "Current value of counter is $counter\n";
24 // Increment and reset counter, protect it with $txn
25 $db->put("counter", $counter+1, $txn);
27 // Commit the transaction, otherwise the above put() will rollback.
29 // Sync for good measure
31 // This isn't a real close, use _close() for that.