dba_popenDescriptiondba_popen() opens a persistent connection to a db file. In this case, persistent means that the connection can remain open after the PHP script exits. This allows the connection to be reused, instead of going through the full process of opening, using, and then closing for every invocation of the script. The function takes three or more arguments. The first argument is the path to the db file. The path can be relative or absolute. The second argument contains a single-character mnemonic indicating in which mode to open the file. The following table lists the valid modes.
The third argument contains the flavor of dbm-style database to use. Valid types include cdb, db2, db3, dbm, gdbm, and ndbm. NoteEach of these dbm-style databases needs to be separately installed if you want to use them with the dba functions. See the beginning of this chapter for information on where to download the various databases. The fourth and subsequent arguments can be used to pass extra parameters directly to the database that's being used to open the db file. ExampleExample 217. Open a persistent read-only connection $db_file = 'state.dbm'; $db_mode = 'r'; $db_handler = 'gdbm'; $dba_handle = dba_popen ($db_file, $db_mode, $db_handler) or die ("A persistent connection to <i>$db_file</i> could not be made using connection mode <i>$db_mode</i> and handler <i>$db_handler</i>");
PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing
(Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch).
This material may be distributed only subject to the terms and conditions set forth
in the Open Publication License, v1.0 or later (the latest version is presently available at
http://www.opencontent.org/openpub/).
The authors of this book have elected not to choose any options under the OPL. This online book was obtained
from http://www.fooassociates.com/phpfer/
and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4
for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All
persons and entities shall have neither liability nor responsibility to any person or entity with respect to
any loss or damage arising from the information contained in this book.
|