DBM Functions

PHP Manual
Prev |  | Next

# XX. DBM Functions

# Introduction

These functions allow you to store records stored in a dbm-style database. This type of database (supported by the Berkeley DB, GDBM, and some system libraries, as well as a built-in flatfile library) stores key/value pairs (as opposed to the full-blown records supported by relational databases).

> Note: However, dbm support is deprecated and you are encourged to use the Database (dbm-style) abstraction layer functions instead.

# Requirements

To use this functions you have to compile PHP with support for an underlying database. See the list of supported Databases.

# Installation

In order to use these functions, you must compile PHP with dbm support by using the `--with-db` option. In addtion you must ensure support for an underlying database or you can use some sytem libraries.

# Runtime Configuration

This extension has no configuration directives defined in `php.ini`.

# Resource Types

The function dbmopen() returns an database identifier which is used by the other dbm-functions.

# Predefined Constants

This extension has no constants defined.

# Examples

Example 1. DBM example
    $dbm = dbmopen ("lastseen", "w");
    if (dbmexists ($dbm, $userid)) {
        $last_seen = dbmfetch ($dbm, $userid);
    } else {
        dbminsert ($dbm, $userid, time());
    }
    do_stuff();
    dbmreplace ($dbm, $userid, time());
    dbmclose ($dbm);

Prev | Home | Next
dbase_replace_record | Up | dblist