queryflatfile
3.1.0

queryflatfileは、PHP で書かれたフラット ファイル データベース ライブラリです。データはデフォルトでJSON形式で保存され、 txt 、 msgPack 、および igbinary 形式もサポートされます。 SQL 構文に似た QueryBuilder を使用してデータを操作します。
| PHPのバージョン | queryflatfile 3.1.x |
|---|---|
| <= 7.1 | ✗ サポートされていません |
| 7.2 / 7.3 / 7.4 | ✓ サポートされています |
| 8.0 / 8.1 / 8.2 | ✓ サポートされています |
txt 、json 、必要なメモリの最小量は、処理するデータの量と操作の種類によって異なります。
データを保存するディレクトリ内のファイルの書き込みと読み取りの権限。
Composer 経由でqueryflatfileインストールするには、インストーラーまたはバイナリ ファイル Composer が必要です。
プロジェクト ディレクトリに移動し、コマンド プロンプトを開いて次のコマンドを実行します。
composer require soosyze/ queryflatfile --no-devまたは、バイナリ ファイルを使用する場合は、
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 ' );上記の例では次のように出力されます。
Array
(
[id] => 2
[name] => DUPOND
)
スキーマ
dropSchema() 、getIncrement( string $tableName ) 、getSchema() 、getTableSchema( string $tableName ) 、hasColumn( string $tableName, $columnName ) ,hasTable( string $tableName ) 、setConfig( string $host, string $name = 'schema', DriverInterface $driver = null ) 。ハンドリングテーブル
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 ) 。選択リクエスト
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 ) 。執行の要請
insertInto( string $tableName, array $columnNames ) ,values( array $rowValues ) 、update( string $tableName, array $row ) ,delete() 、execute()データの挿入、変更、削除を実行します。クエリの結果
fetch(): arrayクエリの最初の結果を返します。fetchAll(): arrayクエリのすべての結果を返します。lists( string $columnName, string $key = null ): arrayパラメータで渡された列のリストを返します。どこ
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 ) 。サポートされる条件 (===、==、!=、<>、<、<=、>、>=、like、ilike、not like、not ilike)
どこ
whereGroup( Closure $columnName ) 、orWhereGroup( Closure $columnName ) 、notWhereGroup( Closure $columnName ) 、orNotWhereGroup( Closure $columnName ) 。間のどこ
between( string $columnName, $min, $max ) ,orBetween( string $columnName, $min, $max ) ,notBetween( string $columnName, $min, $max ) ,orNotBetween( string $columnName, $min, $max ) 。どこで
in( string $columnName, array $values ) ,orIn( string $columnName, array $values ) ,notIn( string $columnName, array $values ) ,orNotIn( string $columnName, array $values ) 。Null はどこにありますか
isNull( string $columnName ) 、orIsNull( string $columnName ) 、isNotNull( string $columnName ) 、orIsNotNull( string $columnName ) 。ここで正規表現
regex( string $columnName, string $pattern ) ,orRegex( string $columnName, string $pattern ) ,notRegex( string $columnName, string $pattern ) ,orNotRegex( string $columnName, string $pattern ) 。 使用例については、ユーザー ドキュメントを参照してください。
このプロジェクトは MIT ライセンスに基づいてライセンスされています。