Skip to content
damon-kronski edited this page Oct 28, 2014 · 2 revisions

Create an instance for use with Cookies

This command creates an instance for use with client-side cookies.

$cookieName = "JsonDB";
$defaultArray = array(array('id' => 1,'name' => 'Test Item 1','value' => 'Lorem Ipsum'));

$JsonDB = JsonDB::withCookie($defaultArray,$cookieName);

Create an instance for use with json file

This command creates an instance for use with a global .json file.

$jsonPath = "data/db.json";
$defaultArray = array(array('id' => 1,'name' => 'Test Item 1','value' => 'Lorem Ipsum'));

$JsonDB = JsonDB::withJson($defaultArray,$jsonPath);

Getting Data

This command returns an array of the database.

$JsonDB->readDB();

Insert Data

This command inserts data into the database.

$JsonDB->addItem(array('name' => 'Added Item','value' => 'Now it is in the database.'));

Update Data

This command updates data of the database.

$JsonDB->setItem(1,array('name' => 'Added Item','value' => 'Now it is in the database.'));

Delete Data

This command deletes data from the database.

$JsonDB->delItem(1);

Getting Started

Getting Started


Initializing

withCookie

withJson


Data Access

addItem

setItem

delItem


Misc

readDB

newId

Clone this wiki locally