2017 © Pedro Peláez
 

library queryjson

The QueryJson PHP framework

image

noelma/queryjson

The QueryJson PHP framework

  • Sunday, June 11, 2017
  • by noelma
  • Repository
  • 1 Watchers
  • 1 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Queryflatfile

Build Status Coverage Status GitHub Packagist PHP from Packagist GitHub code size in bytes, (*1)

About

Queryflatfile is a flat file database library written in PHP. Stores your data by default in JSON format, also supports txt, msgPack and igbinary formats. Manipulate your data with a QueryBuilder similar to SQL syntax., (*2)

Summary

Requirements

PHP version

Version PHP QueryFlatFile 3.1.x
<= 7.1 ✗ Unsupported
7.2 / 7.3 / 7.4 ✓ Supported
8.0 / 8.1 / 8.2 ✓ Supported

Extensions

  • txt for recording data with PHP serialize,
  • json for recording data in JSON format,
  • msgPack for recording data in binary.
  • igbinary for recording data in binary.

Memory required

The minimum amount of memory required depends on the amount of data you are going to process and the type of operations., (*3)

Permission of files and directory

Permission to write and read files in the directory that will store your data., (*4)

Installation

Composer

To install Queryflatfile via Composer you must have the installer or the binary file Composer, (*5)

Go to your project directory, open a command prompt and run the following command:, (*6)

composer require soosyze/queryflatfile --no-dev

Or, if you use the binary file,, (*7)

php composer.phar require soosyze/queryflatfile --no-dev

Simple example

require __DIR__ . '/vendor/autoload.php';

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');

The above example will output:, (*8)

Array
(
    [id] => 2
    [name] => DUPOND
)

Methods

Schema, (*9)

  • dropSchema(),
  • getIncrement( string $tableName ),
  • getSchema(),
  • getTableSchema( string $tableName ),
  • hasColumn( string $tableName, $columnName ),
  • hasTable( string $tableName ),
  • setConfig( string $host, string $name = 'schema', DriverInterface $driver = null ).

Handling tables, (*10)

  • alterTable( string $tableName, callable $callback ),
  • createTable( string $tableName, callable $callback = null ),
  • createTableIfNotExists( string $tableName, callable $callback = null ) :
    • boolean( string $name ),
    • char( string $name, $length = 1),
    • date( string $name ),
    • dateTime( string $name ),
    • float( string $name ),
    • increments( string $name ),
    • integer( string $name ),
    • string( string $name, $length = 255),
    • text( string $name ).
  • dropTable( string $tableName ),
  • dropTableIfExists( string $tableName ),
  • truncateTable( string $tableName ).

Selection request, (*11)

  • select( string ...$columnNames ),
  • from( string $tableName ),
  • leftJoin( string $tableName, \Closure|string $column, string $condition = '', string $value = '' ),
  • rightJoin( string $tableName, \Closure|string $column, string $condition = '', string $value = '' ),
  • union( RequestInterface $union ),
  • unionAll( RequestInterface $union ),
  • orderBy( string $columnName, int $order = SORT_DESC|SORT_ASC ),
  • limit( int $limit, int $offset = 0 ).

Request for execution, (*12)

  • insertInto( string $tableName, array $columnNames ),
  • values( array $rowValues ),
  • update( string $tableName, array $row ),
  • delete(),
  • execute() Performs the insertion, modification and deletion of data.

Result(s) of the query, (*13)

  • fetch(): array Returns the first result of the query,
  • fetchAll(): array Returns all the results of the query,
  • lists( string $columnName, string $key = null ): array Returns a list of the column passed in parameter.

Where, (*14)

  • where( string $columnName, string $condition, null|scalar $value ),
  • orWhere( string $columnName, string $condition, null|scalar $value ),
  • notWhere( string $columnName, string $condition, null|scalar $value ),
  • orNotWhere( string $columnName, string $condition, null|scalar $value ).

Supported conditions (===, ==, !=, <>, <, <=, >, >=, like, ilike, not like, not ilike), (*15)

Where, (*16)

  • whereGroup( \Closure $columnName ),
  • orWhereGroup( \Closure $columnName ),
  • notWhereGroup( \Closure $columnName ),
  • orNotWhereGroup( \Closure $columnName ).

Where between, (*17)

  • between( string $columnName, $min, $max ),
  • orBetween( string $columnName, $min, $max ),
  • notBetween( string $columnName, $min, $max ),
  • orNotBetween( string $columnName, $min, $max ).

Where in, (*18)

  • in( string $columnName, array $values ),
  • orIn( string $columnName, array $values ),
  • notIn( string $columnName, array $values ),
  • orNotIn( string $columnName, array $values ).

Where isNull, (*19)

  • isNull( string $columnName ),
  • orIsNull( string $columnName ),
  • isNotNull( string $columnName ),
  • orIsNotNull( string $columnName ).

Where regex, (*20)

  • regex( string $columnName, string $pattern ),
  • orRegex( string $columnName, string $pattern ),
  • notRegex( string $columnName, string $pattern ),
  • orNotRegex( string $columnName, string $pattern ).

Usage

For examples of uses, refer to the user documentation., (*21)

License

This project is licensed under the MIT license., (*22)

The Versions

11/06 2017

1.0.0

1.0.0.0

The QueryJson PHP framework

  Sources   Download

The Requires

  • php >=5.4

 

The Development Requires

framework