/JSONdb

Simple file-base data storage

Primary LanguagePHPGNU General Public License v3.0GPL-3.0

JSONdb

// Work In Progress

Simple file-base data storage

installation

Move 'JSONdb.php' file to your class folder. After that you can import JSONdb to your project like this

require_once "classes/JSONdb.php";

usage

First of all, create a JSONdb.

$db = new JSONdb("db.json", [
	"name",
	"secondName"
]);

Then you can use JSONdb methods.

insert

Add a data to the database.

$db->insert([
	"name" => "batu",
	"secondName" => "berk"
]);

getFullContent

Get all data in database.

$users = $db->getFullContent();

foreach($users as $user) {
    echo 'First name: ' . $user->name . '<br>';
    echo 'Second name: ' . $user->secondName . '<br>';
    echo '-------<br>';
}

Output:

First name: batu
Second name: berk
-------
First name: batu
Second name: sahin
-------
First name: berk
Second name: sahin
-------

getContentById

Get data by id.

$data = $db->getContentById($_GET["id"]);

This method returns an array.

deleteById

Delete data by id.

$db->deleteById($_GET["id"]);

LICENSE

GNU General Public License v3.0