PHP code example of soosyze / queryflatfile

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

    

soosyze / queryflatfile example snippets




use Soosyze\Queryflatfile\Schema;
use Soosyze\Queryflatfile\Request;
use Soosyze\Queryflatfile\TableBuilder;
use Soosyze\Queryflatfile\Driver\Json;

$sch = new Schema(__DIR__ . 'data', 'schema', new Json());
$req = new Request($sch);

$sch->createTableIfNotExists('user', function(TableBuilder $table): void {
    $table->increments('id')
    $table->string('name')
    $table->string('firstname')->nullable();
});

$req->insertInto('user', [ 'name', 'firstname' ])
    ->values([ 'NOEL', 'Mathieu' ])
    ->values([ 'DUPOND', 'Jean' ])
    ->values([ 'MARTIN', null ])
    ->execute();

$data = $req->select('id', 'name')
    ->from('user')
    ->where('firstname', '=', 'Jean')
    ->fetch();

print_r($data);

$sch->dropTableIfExists('user');