Use json az database for small projects with this class
First load the class via include_once
or require_once
:
include_once("json_db.php");
Then create variable and load the class:
$database = new JsonDatabase('your_json_path.json'); // or even you can use url as a path
Now everything is ready to use!
echo $database->db->data_key;
$database->db->data_key = "Hello world!";
The class has auto save option, and its turned on by default. it means everytime you change value, the class will save it.
But for turning off the auto save, just add fase
as seconed parameter, Example:
$database = new JsonDatabase('your_json_path.json',false); // By adding false as second parameter, we Disable auto save option
Now if you edit a key, you show call save()
function, Example:
$database = new JsonDatabase('your_json_path.json',false);
$database->db->data_key = "Hello world!";
$database->save();