PHP code example of fernandothedev / jsonsql

1. Go to this page and download the library: Download fernandothedev/jsonsql 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/ */

    

fernandothedev / jsonsql example snippets




use Fernando\\JsonSQL;

/file.json';

$jsonsql = new JsonSQL($file);

// return true
$jsonsql->insert(key: 'fernandothedev', array: [
    'name' => 'Fernando',
    'age' => 16,
    'love' => 'php'
]);

// return false [ user not exists ]
var_dump($jsonsql->select(key: 'fernando'));

// return array [ user exists ]
print_r($jsonsql->select(key: 'fernandothedev'));

// return array<T>
var_dump($jsonsql->select(key: 'fernandothedev', array: [
    'name'
]));

// return true { update [ unic user ] }
$jsonsql->update(key: 'fernandothedev', array: [
    'love' => 'water'
]);

sleep(seconds: 3);

// retur true { update [ all users ] }
var_dump($jsonsql->update(array: [
    'love' => 'money'
]));

// return false [ user not exists ]
$jsonsql->delete(key: 'fernando2');

// return false [ key not exists ]
$jsonsql->delete(key: 'fernando', array: [
    'key-dont-exists'
]);

// return true [ user deleted ]
$jsonsql->delete(key: 'fulano');

// return true { user [ key deleted ] }
$jsonsql->delete(key: 'fernandothedev', array: [
    'love'
]);
 
file.json: {}