
queryflatfile é uma biblioteca de banco de dados de arquivo simples escrita em PHP. Armazena seus dados por padrão no formato JSON , também suporta os formatos txt , msgPack e igbinary. Manipule seus dados com um QueryBuilder semelhante à sintaxe SQL.
| Versão PHP | queryflatfile 3.1.x |
|---|---|
| <= 7,1 | ✗ Não suportado |
| 7,2/7,3/7,4 | ✓ Suportado |
| 8,0/8,1/8,2 | ✓ Suportado |
txt para gravar dados com serialização PHP,json para gravar dados no formato JSON,A quantidade mínima de memória necessária depende da quantidade de dados que você irá processar e do tipo de operações.
Permissão para gravar e ler arquivos no diretório que armazenará seus dados.
Para instalar queryflatfile via Composer você deve ter o instalador ou o arquivo binário Composer
Vá para o diretório do seu projeto, abra um prompt de comando e execute o seguinte comando:
composer require soosyze/ queryflatfile --no-devOu, se você usar o arquivo binário,
php composer.phar require soosyze/ queryflatfile --no-dev 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 ' );O exemplo acima produzirá:
Array
(
[id] => 2
[name] => DUPOND
)
Esquema
dropSchema() ,getIncrement( string $tableName ) ,getSchema() ,getTableSchema( string $tableName ) ,hasColumn( string $tableName, $columnName ) ,hasTable( string $tableName ) ,setConfig( string $host, string $name = 'schema', DriverInterface $driver = null ) .Manipulando tabelas
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 ) .Solicitação de seleção
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 ) .Pedido de execução
insertInto( string $tableName, array $columnNames ) ,values( array $rowValues ) ,update( string $tableName, array $row ) ,delete() ,execute() Executa a inserção, modificação e exclusão de dados.Resultado(s) da consulta
fetch(): array Retorna o primeiro resultado da consulta,fetchAll(): array Retorna todos os resultados da consulta,lists( string $columnName, string $key = null ): array Retorna uma lista da coluna passada no parâmetro.Onde
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 ) .Condições suportadas (===, ==, !=, <>, <, <=, >, >=, gosto, gosto, não gosto, não gosto)
Onde
whereGroup( Closure $columnName ) ,orWhereGroup( Closure $columnName ) ,notWhereGroup( Closure $columnName ) ,orNotWhereGroup( Closure $columnName ) .Onde entre
between( string $columnName, $min, $max ) ,orBetween( string $columnName, $min, $max ) ,notBetween( string $columnName, $min, $max ) ,orNotBetween( string $columnName, $min, $max ) .Onde em
in( string $columnName, array $values ) ,orIn( string $columnName, array $values ) ,notIn( string $columnName, array $values ) ,orNotIn( string $columnName, array $values ) .Onde está Nulo
isNull( string $columnName ) ,orIsNull( string $columnName ) ,isNotNull( string $columnName ) ,orIsNotNull( string $columnName ) .Onde regex
regex( string $columnName, string $pattern ) ,orRegex( string $columnName, string $pattern ) ,notRegex( string $columnName, string $pattern ) ,orNotRegex( string $columnName, string $pattern ) . Para exemplos de usos, consulte a documentação do usuário.
Este projeto está licenciado sob a licença do MIT.