
queryflatfile adalah perpustakaan database file datar yang ditulis dalam PHP. Menyimpan data Anda secara default dalam format JSON , juga mendukung format txt , msgPack dan igbinary. Memanipulasi data Anda dengan QueryBuilder yang mirip dengan sintaksis SQL.
| Versi PHP | queryflatfile 3.1.x |
|---|---|
| <= 7.1 | ✗ Tidak didukung |
| 7.2 / 7.3 / 7.4 | ✓ Didukung |
| 8.0 / 8.1 / 8.2 | ✓ Didukung |
txt untuk merekam data dengan serialisasi PHP,json untuk merekam data dalam format JSON,Jumlah minimum memori yang diperlukan bergantung pada jumlah data yang akan Anda proses dan jenis operasinya.
Izin untuk menulis dan membaca file di direktori yang akan menyimpan data Anda.
Untuk menginstal queryflatfile melalui Composer Anda harus memiliki installer atau file biner Composer
Buka direktori proyek Anda, buka prompt perintah dan jalankan perintah berikut:
composer require soosyze/ queryflatfile --no-devAtau, jika Anda menggunakan file biner,
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 ' );Contoh di atas akan menampilkan:
Array
(
[id] => 2
[name] => DUPOND
)
Skema
dropSchema() ,getIncrement( string $tableName ) ,getSchema() ,getTableSchema( string $tableName ) ,hasColumn( string $tableName, $columnName ) ,hasTable( string $tableName ) ,setConfig( string $host, string $name = 'schema', DriverInterface $driver = null ) .Menangani meja
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 ) .Permintaan seleksi
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 ) .Permintaan eksekusi
insertInto( string $tableName, array $columnNames ) ,values( array $rowValues ) ,update( string $tableName, array $row ) ,delete() ,execute() Melakukan penyisipan, modifikasi dan penghapusan data.Hasil kueri
fetch(): array Mengembalikan hasil pertama dari kueri,fetchAll(): array Mengembalikan semua hasil kueri,lists( string $columnName, string $key = null ): array Mengembalikan daftar kolom yang diteruskan dalam parameter.Di mana
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 ) .Kondisi yang didukung (===, ==, !=, <>, <, <=, >, >=, like, ilike, not like, not ilike)
Di mana
whereGroup( Closure $columnName ) ,orWhereGroup( Closure $columnName ) ,notWhereGroup( Closure $columnName ) ,orNotWhereGroup( Closure $columnName ) .Dimana antara
between( string $columnName, $min, $max ) ,orBetween( string $columnName, $min, $max ) ,notBetween( string $columnName, $min, $max ) ,orNotBetween( string $columnName, $min, $max ) .Dimana di
in( string $columnName, array $values ) ,orIn( string $columnName, array $values ) ,notIn( string $columnName, array $values ) ,orNotIn( string $columnName, array $values ) .Dimana Null
isNull( string $columnName ) ,orIsNull( string $columnName ) ,isNotNull( string $columnName ) ,orIsNotNull( string $columnName ) .Dimana regex
regex( string $columnName, string $pattern ) ,orRegex( string $columnName, string $pattern ) ,notRegex( string $columnName, string $pattern ) ,orNotRegex( string $columnName, string $pattern ) . Untuk contoh penggunaan, lihat dokumentasi pengguna.
Proyek ini dilisensikan di bawah lisensi MIT.