2017 © Pedro Peláez
 

library json-simple-db

Work with JSON file like with a simple database

image

mhujer/json-simple-db

Work with JSON file like with a simple database

  • Saturday, December 12, 2015
  • by mhujer
  • Repository
  • 2 Watchers
  • 1 Stars
  • 28 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 4 % Grown

The README.md

JSON SimpleDB Build Status

Latest Stable Version Total Downloads License Coverage Status, (*1)

For a project that generates static HTML I needed a data source, so I created this simple library for storing data in JSON. It is intended only for CLI usage by a single client, not for websites!, (*2)

Usage

  1. Install the latest version with composer require mhujer/json-simple-db
  2. Use it according to the example bellow and check the docblocks
<?php
require_once 'vendor/autoload.php';

//initialize DB
$db = new JsonSimpleDb\Db('./foo');

//initialize table
if (!$db->tableExists('mytable')) {
    $db->createTable('mytable');
}
$table = $db->getTable('mytable');

//get items count
$table->count(); //0

//insert into table
$table->insert([
    'id' => '1',
    'name' => 'foo',
]);

//find by array - like in MongoDB
$items = $table->find(['id' => '1']);
/*
array(1) {
  [0] =>
  array(2) {
    'id' =>
    string(1) "1"
    'name' =>
    string(3) "foo"
  }
}
 */

//update record
$table->update(['id' => '1'], ['name' => 'boo']);

//delete record
$table->delete(['id' => '1']);

//persist the data to file - don't forget this :-)
$table->persist();


Requirements

JSON SimpleDB works with PHP 5.6 or PHP 7., (*3)

Submitting bugs and feature requests

Bugs and feature request are tracked on GitHub, (*4)

Author

Martin Hujer - mhujer@gmail.com - http://www.martinhujer.cz, (*5)

Changelog

1.1.1 (2015-11-26)

  • Stored JSON is pretty printed

1.1.0 (2015-11-26)

  • Added posibility to delete records

1.0.1 (2015-11-17)

  • Comparator does strict matching

1.0.0 (2015-11-14)

  • initial release

The Versions

12/12 2015

dev-master

9999999-dev https://github.com/mhujer/json-simple-db

Work with JSON file like with a simple database

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

database json

26/11 2015

1.1.1

1.1.1.0 https://github.com/mhujer/json-simple-db

Work with JSON file like with a simple database

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

database json

26/11 2015

1.1.0

1.1.0.0 https://github.com/mhujer/json-simple-db

Work with JSON file like with a simple database

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

database json

17/11 2015

1.0.1

1.0.1.0 https://github.com/mhujer/json-simple-db

Work with JSON file like with a simple database

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

database json

14/11 2015

1.0.0

1.0.0.0 https://github.com/mhujer/json-simple-db

Work with JSON file like with a simple database

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

database json