2017 © Pedro Peláez
 

library jsonfiledb

json database library for PHP

image

nyankod/jsonfiledb

json database library for PHP

  • Tuesday, October 25, 2016
  • by yllumi
  • Repository
  • 4 Watchers
  • 1 Stars
  • 50 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 50 Forks
  • 0 Open issues
  • 7 Versions
  • 2 % Grown

The README.md

JSON DB

Forked From philwc/JsonDB with many modifications, (*1)

Handle JSON-Files like a very, very simple DB. Useful for little ajax applications., (*2)

Example:, (*3)

test.json, (*4)

[
{"ID": 0, "Name": "Josef Brunzer", "Age": 43},
{"ID": 1, "Name": "Harald Beidlpraka", "Age": 34},
{"ID": 2, "Name": "Heinz Goschnfuada", "Age": 67},
{"ID": 3, "Name": "Gerald Ofnsacka", "Age": 43}
]

test.php, (*5)

require '../vendor/autoload.php';
$db = new \nyankod\JsonDB('./data/');
$db->setTable('test');
$result = $db->select('Age', 43);
var_dump($result);

result:, (*6)

array(2) {
  [0]=> array(3) { ["ID"]=> int(0) ["Name"]=> string(13) "Josef Brunzer" ["Age"]=> int(43) }
  [1]=> array(3) { ["ID"]=> int(3) ["Name"]=> string(15) "Gerald Ofnsacka" ["Age"]=> int(43) }
}

The default extension is .json. If you want to use a different file extension as ".dat" or whatever, set it in second parameter when create object, $db = new \nyankod\JsonDB('./data/', '.dat');, (*7)


Method Overview

JsonDB -> setTable ( "tablename" ) - Set tablename or create table file if not exist. This method have to always be called before doing data transaction., (*8)

JsonDB -> select ( "key", "value" ) - Selects multiple lines which contains the key/value and returns it as array, (*9)

JsonDB -> selectAll () - Returns the entire file as array, (*10)

JsonDB -> update ( "key", "value", ARRAY ) - Replaces the line which corresponds to the key/value with the array-data, (*11)

JsonDB -> updateAll ( ARRAY ) - Replaces the entire file with the array-data, (*12)

JsonDB -> insert ( ARRAY ) - Appends a row, returns true on success, (*13)

JsonDB -> delete ( "key", "value" ) - Deletes all lines which corresponds to the key/value, returns number of deleted lines, (*14)

JsonDB -> deleteAll () - Deletes the whole data, returns "true" on success, (*15)


Installation

Just download the latest release and extract to your project, or using composer with package name nyankod/jsonfiledb., (*16)

The Versions

25/10 2016

dev-master

9999999-dev https://github.com/codepolitan-lab/JsonFileDB

json database library for PHP

  Sources   Download

MIT

by Toni Haryanto

database json db

25/10 2016

v0.2.3

0.2.3.0 https://github.com/nyankod/JsonFileDB

json database library for PHP

  Sources   Download

MIT

by Toni Haryanto

database json db

25/10 2016

v0.3.0

0.3.0.0 https://github.com/nyankod/JsonFileDB

json database library for PHP

  Sources   Download

MIT

by Toni Haryanto

database json db

13/11 2014

v0.2.2

0.2.2.0 https://github.com/nyankod/JsonFileDB

json database library for PHP

  Sources   Download

MIT

by Toni Haryanto

database json db

13/11 2014

v0.2.1

0.2.1.0 https://github.com/nyankod/JsonFileDB

json database library for PHP

  Sources   Download

MIT

by Toni Haryanto

database json db

13/11 2014

v0.2

0.2.0.0 https://github.com/nyankod/JsonFileDB

json database library for PHP

  Sources   Download

MIT

by Toni Haryanto

database json db

08/05 2014

v0.1

0.1.0.0 https://github.com/philwc/JsonDB

Database using json

  Sources   Download

MIT

by Phil Wright- Christie

database json db