PHP code example of andkom / php-berkeley-db

1. Go to this page and download the library: Download andkom/php-berkeley-db library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

andkom / php-berkeley-db example snippets


use AndKom\BerkeleyDb\Adapter\AdapterFactory;

$adapter = AdapterFactory::create(); // use first available adapter
$adapter = AdapterFactory::create("phpdb4"); // use phpdb4 adapter
$adapter = AdapterFactory::create("dba"); // use dba adapter

$adapter->open("filename", "r");

$adapter->open("filename", "r", "main");

$adapter->open("filename", "w");

$adapter->close();

$adapter->sync();

$value = $adapter->get("key");

$adapter->put("key", "value");

$adapter->delete("key");

$adapter->firstKey();

$adapter->nextKey();

foreach ($adapter->read() as $key => $value) {
    ...
}


 
return [
    'adapter' => 'phpdb4',
 
    'filename' => database_path('database.dat'),
 
    'database' => null,
 
    'mode' => 'w',
];


$value = BDB::get("key");
bash
composer install andkom/php-berkeley-db