This project provides a simple, file-based JSON database for small-scale web applications. It includes built-in encryption and various functions for database control, data access, and manipulation.
Before using this database, change the default encryption key (key), Extra encryption key (Ekey) and initialization vector (IV) in config.php to ensure security.
Include connect.php in your project:
require_once 'connect.php';
$sdb = new SwartzDB('<database_path>');
$sdb->create('users');
Default database_path, if left empty is a folder called storage in the SwartzDB folder.
$data = ['id' => 1, 'name' => 'John Doe', 'email' => 'john@example.com'];
$sdb->add_row('users', $data);
$user = $sdb->get_row('users', ['id' => 1, 'name' => 'John Doe']);
print_r($user);
$update = ['email' => 'newemail@example.com'];
$sdb->update_row('users', ['id' => 1, 'name' => 'John Doe'], $update);
$sdb->remove_row('users', ['id' => 1, 'name' => 'John Doe']);
A detailed documentation with examples and more details into Aggregate and Filter function, will be released soon.
This is a fun and learning project, not meant for production or large-scale systems. SwartzBD is designed for small-scale PHP websites that need simple data storage and retrieval. If you require high-performance, concurrent, or large-scale database operations, consider using SQL-based databases or more robust NoSQL solutions like MongoDB.
This project is dedicated to Aaron Swartz, a visionary in open access and digital freedom.