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 serialize،json
لتسجيل البيانات بتنسيق 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 )
.الشروط المدعومة (===، ==، !=، <>، <، <=، >، >=، مثل، 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.