Skip to content

ArkaDB is a simple CRUD like database implemented in PHP without any third-party dependencies that store data in JSON files.

License

Notifications You must be signed in to change notification settings

Arkaneel/ArkaDB

Repository files navigation

ArkaDB

A simple CRUD Database made with ❤️ and PHP.

ArkaDB is a simple CRUD like database implemented in PHP without any third-party dependencies that store data in JSON files.

It's not comparable with databases like SQL but you can compare it with databases like MongoDB.


Motivation

I'm Arkaneel Roy I'm 15 (2023) and I created it as a hobby project but with the help contribution of you all I wanna expand this project.


Features

  • Extremely Lightweight {3kb}
  • Supports Basics Like Create Read Update and Delete.
  • Embedable DB.
  • Stores Data as Object.
  • Generates a unique id for each object named as Static Key.
  • Extensible with PHP.
  • Highly Suitable for CMS and LMS etc.

Installation

  • Download the latest from the releases and add it to your project.

  • Download

  • Alternatively you can clone this repo.

git clone https://github.com/Arkaneel/ArkaDB

Then include it as :

include 'ArkaDB/ArkaDB.php';

Initialization

  • Initialization :
$database = ArkaDB('Name of Your Database','Name of Your Database Folder');
  • For Example :
$database = ArkaDB('database','db');

This creates a database named database.json in the folder db


Supported Functions

Function Usage
insert() Inserts Data.
get() Gets Data through `Static Key`.
getAll() Gets all the Data registered in the database.
update() Updates Data registered in the database.
delete() Deletes Data using `Static Key`.

Example Usages.

1.insert( )

$database = new ArkaDB('data', 'data_folder');

$data = [
  'name' => 'John Doe',
  'email' => 'johndoe@example.com',
  'age' => 25
];

$id = $database->insert($data);


echo "Inserted data with ID: " . $id;

2.Get( )

$database = new ArkaDB('data', 'data_folder');


$id = 'static-key';

$data = $database->get($id);


if ($data) {
  echo "Retrieved data:\n";
  print_r($data);
} else {
  echo "Data not found.";
}

3.GetAll( )

$database = new ArkaDB('data', 'data_folder');


$allData = $database->getAll();


echo "All data:\n";
print_r($allData);

4.update( )

$arkaDB = new ArkaDB('data', 'data_folder');


$id = 'static-key'; 
$newData = [
  'name' => 'John Doe',
  'email' => 'johndoe@example.com',
  'age' => 30
];


$result = $arkaDB->update($id, $newData);

if ($result) {
  echo "Data updated successfully.";
} else {
  echo "Failed to update data.";
}

5.delete( )

$database = new ArkaDB('data', 'data_folder');


$id = 'static-key';


$deleted = $database->delete($id);


if ($deleted) {
  echo "Data with ID $id deleted successfully.";
} else {
  echo "Data not found.";
}

If you like this then please share it to twitter:


About

ArkaDB is a simple CRUD like database implemented in PHP without any third-party dependencies that store data in JSON files.

Resources

License

Stars

Watchers

Forks