Home > Articles > Programming > PHP

Working with PHP's DBA Functions

  • Print
  • + Share This
The DBA functions provide you with a simple but powerful means of saving and accessing data. This lesson looks at these functions, and uses examples to show them in action.

See all Sams Teach Yourself on InformIT Web Development Tutorials.

This chapter is from the book

If you don't have access to a SQL database such as MySQL or Oracle, you will almost certainly have a DBM-style database system available to you. DBM stands for database manager and DBM-like systems allow you to store and manipulate name/value pairs on your system.

DBA stands for Database abstraction layer, and these functions are designed to provide a common interface to a range of file-based database systems.

Although DBA functions do not offer you the power of a SQL database, they are flexible and easy to use. The fact that DBA functions stand above a range of common database systems, means that your code is likely to be portable even if the database files themselves might not be.

In this hour, you will learn:

  • How to open a database

  • How to add data to the database

  • How to extract data from the database

  • How to change and delete items

  • How to store more complex kinds of data in DBM-style databases

Beneath the Abstraction

In order to use the DBA functions, you need to have one of the supported database systems installed. If you are running Linux, it is likely that you will have GDBM (the GNU Database Manager installed). For each system there is a corresponding compile option which should have been used when PHP was installed. You can see the supported databases and their corresponding compile options in Table 11.1.

Table 11.1 DBM systems supported by the DBA functions


Compile option

Further information



Read-only database system









The original DBM. Deprecated



GNU Database Manager




If your system and PHP installation supports one of these systems you will be able to use the DBA functions with no problems. Note that support for the cdbm system (which is designed for fast access to static databases) is read-only.

  • + Share This
  • 🔖 Save To Your Account