// Work In Progress
Simple file-base data storage
Move 'JSONdb.php' file to your class folder. After that you can import JSONdb to your project like this
require_once "classes/JSONdb.php";
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"]);