PHP code example of philwc / jsondb

1. Go to this page and download the library: Download philwc/jsondb library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

philwc / jsondb example snippets


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) }
}

JsonDB->select ( "table", "key", "value" ) //Selects multiple lines which contains the key/value and returns it as array
JsonDB->selectAll ( "table" ) //Returns the entire file as array
JsonDB->update ( "table", "key", "value", ARRAY ) //Replaces the line which corresponds to the key/value with the array-data
JsonDB->updateAll ( "table", ARRAY ) //Replaces the entire file with the array-data
JsonDB->insert ( "table", ARRAY ) //Appends a row, returns true on success
JsonDB->delete ( "table", "key", "value" ) //Deletes all lines which corresponds to the key/value, returns number of deleted lines
JsonDB->deleteAll ( "table" ) //Deletes the whole data, returns "true" on success
JsonDB->setPrettyOutput ( "table", bool ) //Set Pretty Output for json_encode
JsonDB->setJsonEncodeOptions ( "table", int ) //Set options for json_encode
JsonDB->setExtension( "newExtension" ) //Set the file extension to use

$db     = new \philwc\JsonTable('./data/test.json');
$result = $db->select('Age', 43);
var_dump($result);