
queryflatfile เป็นไลบรารีฐานข้อมูลไฟล์แบบแฟลตที่เขียนด้วย PHP จัดเก็บข้อมูลของคุณตามค่าเริ่มต้นในรูปแบบ JSON และยังรองรับรูปแบบ txt , msgPack และ igbinary จัดการข้อมูลของคุณด้วย QueryBuilder ที่คล้ายกับไวยากรณ์ SQL
| เวอร์ชัน PHP | queryflatfile 3.1.x |
|---|---|
| <= 7.1 | ✗ ไม่รองรับ |
| 7.2 / 7.3 / 7.4 | ✓ รองรับ |
| 8.0 / 8.1 / 8.2 | ✓ รองรับ |
txt สำหรับบันทึกข้อมูลด้วย PHP serializejson สำหรับบันทึกข้อมูลในรูปแบบ JSONจำนวนหน่วยความจำขั้นต่ำที่ต้องการขึ้นอยู่กับปริมาณข้อมูลที่คุณจะประมวลผลและประเภทของการดำเนินการ
สิทธิ์ในการเขียนและอ่านไฟล์ในไดเร็กทอรีที่จะจัดเก็บข้อมูลของคุณ
หากต้องการติดตั้ง queryflatfile ผ่าน Composer คุณต้องมีตัวติดตั้งหรือ 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 )เงื่อนไขที่รองรับ (===, ==, !=, <>, <, <=, >, >=, ชอบ, ชอบ, ไม่ชอบ, ไม่ใช่ไม่ชอบ)
ที่ไหน
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 ) .ว่างตรงไหน.
isNull( string $columnName ) ,orIsNull( string $columnName ) ,isNotNull( string $columnName ) ,orIsNotNull( string $columnName )ที่ไหน regex
regex( string $columnName, string $pattern ) ,orRegex( string $columnName, string $pattern ) ,notRegex( string $columnName, string $pattern ) ,orNotRegex( string $columnName, string $pattern ) สำหรับตัวอย่างการใช้งาน โปรดดูเอกสารประกอบสำหรับผู้ใช้
โครงการนี้ได้รับอนุญาตภายใต้ใบอนุญาต MIT