Flintstone - Examples

<?php

// Set options
$options = ['dir' => '/path/to/database/dir/'];

// Load the databases
$users = new Flintstone('users', $options);
$settings = new Flintstone('settings', $options);

// Set keys
$users->set('bob', ['email' => 'bob@site.com', 'password' => '123456']);
$users->set('joe', ['email' => 'joe@site.com', 'password' => 'test']);
$settings->set('site_offline', 1);
$settings->set('site_back', '3 days');

// Retrieve keys
$user = $users->get('bob');
echo 'Bob, your email is ' . $user['email'];

$offline = $settings->get('site_offline');
if ($offline == 1) {
	echo 'Sorry, the website is offline<br />';
	echo 'We will be back in ' . $settings->get('site_back');
}

// Retrieve all key names
$keys = $users->getKeys(); // returns array('bob', 'joe', ...)

foreach ($keys as $username) {
	$user = $users->get($username);
	echo $username.', your email is ' . $user['email'];
	echo $username.', your password is ' . $user['password'];
}

// Delete a key
$users->delete('joe');

// Flush the database
$users->flush();