PHP Classes
elePHPant
Icontem

PHP Slim JSON DB: Create and manage a database in a JSON format file

Recommend this page to a friend!
  Info   View files Documentation   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2014-08-25 (5 years ago) RSS 2.0 feedNot enough user ratingsTotal: 286 All time: 7,388 This week: 261Up
Version License PHP version Categories
slim-json-db 1.0.0MIT/X Consortium ...5PHP 5, Databases, Files and Folders
Description Author

This class can create and manage a database in a JSON format file.

It can create a database with the definition of tables and records that is stored in a file serialized in JSON format.

It can create tables and perform select, insert, update and delete table records.

  Performance   Level  
Name: Aminu Ibrahim Bakori <contact>
Classes: 1 package by
Country: Nigeria Nigeria
Age: 23
All time rank: 375725 in Nigeria Nigeria
Week rank: 672 Up9 in Nigeria Nigeria Up

 

Details

SlimDB

SlimDB is a simple inplementation of JSON document database purely written in PHP.

Examples

Open Database

<?php

require 'SlimDB.php';

$db = new SlimDB()-open("db.slim");

?> Output in db.slim

{"name":"db\r\n","tables":{},"data":{}}

Create Table

<?php

require 'SlimDB.php';

$db = new SlimDB()-open("db.slim");
$db->newTable('{"name": "tblusers", "cols": ["name", "age", "gender"]}');

?> Output in db.slim

{"name":"db\r\n","tables":{"tblusers":["_id","name","age", "gender", "created_at","updated_at"]},"data":{"tblusers":[]}}

Drop Table

<?php

require 'SlimDB.php';

$db = new SlimDB()-open("db.slim");
$db->dropTable("tblusers");

?> Output in db.slim

{"name":"db\r\n","tables":{},"data":{}}

Select Table

<?php

require 'SlimDB.php';

$db = new SlimDB()-open("db.slim");
$db->setTable("`tblusers");

?>

Insert Data

<?php

require 'SlimDB.php';

$db = new SlimDB()-open("db.slim");
$db
	->setTable("`tblusers")
	->insert('{"name": "Aminu Bakori", "age": "100", "gender": "Male"}');

?> Output in db.slim

{"name":"db\r\n","tables":{"tblusers":["_id","name","age", "gender", "created_at","updated_at"]},"data":{"tblusers":[{"_id": "53f934f03333340880001e9b","name": "Aminu Bakori","age": "100","gender": "Male","created_at":"2014-08-24 2:42:24","updated_at":"2014-08-24 3:22:48"}]}}

Select Data

<?php

require 'SlimDB.php';

$db = new SlimDB()-open("db.slim");
$db
	->setTable("`tblusers")
	->insert('{"name": "Aminu Bakori", "age": "100"}');

?> Output in browser

array (size=1) 0 =>

object(stdClass)[2]
  public '_id' => string '53f934f03333340880001e9b' (length=24)
  public 'name' => string 'Aminu Bakori' (length=12)
  public 'age' => string '100' (length=3)
  public 'created_at' => string '2014-08-24 2:42:24' (length=18)
  public 'updated_at' => string '2014-08-24 3:22:48' (length=18)

Update Data

<?php

require 'SlimDB.php';

$db = new SlimDB()-open("db.slim");
$db
	->setTable("`tblusers")
	->update('{"where": {"_id": "53f934f03333340880001e9b"}, "set": {"age": "200"}}');

?> Output in db.slim

{"name":"db\r\n","tables":{"tblusers":["_id","name","age", "gender", "created_at","updated_at"]},"data":{"tblusers":[{"_id": "53f934f03333340880001e9b","name": "Aminu Bakori","age": "200","gender": "Male","created_at":"2014-08-24 2:42:24","updated_at":"2014-08-24 3:22:48"}]}}

Delete Data

<?php

require 'SlimDB.php';

$db = new SlimDB()-open("db.slim");
$db
	->setTable("`tblusers")
	->delete('{"name": "Aminu Bakori"}');

?> Output in db.slim

{"name":"db\r\n","tables":{"tblusers":["_id","name","age", "gender", "created_at","updated_at"]},"data":{"tblusers":[]}}

/ * Slim Database. * @author Aminu Ibrahim Bakori <aminuibakori@live.com> * @version 1.0.0 * @license The MIT License (MIT) * @copyright Copyright (c) <2014> <Aminu Ibrahim Bakori> * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */

  Files folder image Files  
File Role Description
Accessible without login Plain text file README.md Doc. Read Me
Plain text file SlimDB.php Class Main Class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:286
This week:0
All time:7,388
This week:261Up