PHP code example of hanneskod / yaysondb

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

    

hanneskod / yaysondb example snippets


use hanneskod\yaysondb\Yaysondb;
use hanneskod\yaysondb\Engine\FlysystemEngine;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;

$db = new Yaysondb([
    'table' => new FlysystemEngine(
        'data.json',
        new Filesystem(new Local('path-to-files'))
    )
]);

$db->table === $db->collection('table');

$db->table->insert(['name' => 'foobar']);

$db->table->commit();

use hanneskod\yaysondb\Operators as y;

// Find all documents with an address in new york
$result = $db->table->find(
    y::doc([
        'address' => y::doc([
            'town' => y::regexp('/new york/i')
        ])
    ])
);

// The result set is filterable
foreach ($result->limit(2) as $id => $doc) {
    // iterate over the first 2 results
}