Opening a Database

You can open a DBM-like database with the function dba_open(). This function requires three arguments: the path to the database file, a string containing the flags with which you want to open the database, and a string representing the database manager you want to work with (the “Type” column in Table 12.1). dba_open() returns a DBA resource that you can then pass to other DBA functions to access or manipulate your database. Because dba_open() involves reading from and writing to files, PHP must have permission to write to the directory that will contain your database.

The flags you pass to dba_open() determine the way in which you can work with your database. They are listed in Table 12.2.

Table 12.2. Flags for Use with ...

Get Sams Teach Yourself PHP in 24 Hours, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.