soosyze/queryflatfile
Composer 安装命令:
composer require soosyze/queryflatfile
包简介
The Queryflatfile is PHP library for simple database not SQL
关键字:
README 文档
README
About
Queryflatfile is a flat file database library written in PHP.
Stores your data by default in JSON format, also supports txt, msgPack and igbinary formats.
Manipulate your data with a QueryBuilder similar to SQL syntax.
Summary
Requirements
PHP version
| Version PHP | QueryFlatFile 3.1.x |
|---|---|
| <= 7.1 | ✗ Unsupported |
| 7.2 / 7.3 / 7.4 | ✓ Supported |
| 8.0 / 8.1 / 8.2 | ✓ Supported |
Extensions
txtfor recording data with PHP serialize,jsonfor recording data in JSON format,- msgPack for recording data in binary.
- igbinary for recording data in binary.
Memory required
The minimum amount of memory required depends on the amount of data you are going to process and the type of operations.
Permission of files and directory
Permission to write and read files in the directory that will store your data.
Installation
Composer
To install Queryflatfile via Composer you must have the installer or the binary file Composer
Go to your project directory, open a command prompt and run the following command:
composer require soosyze/queryflatfile --no-dev
Or, if you use the binary file,
php composer.phar require soosyze/queryflatfile --no-dev
Simple example
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');
The above example will output:
Array
(
[id] => 2
[name] => DUPOND
)
Methods
Schema
dropSchema(),getIncrement( string $tableName ),getSchema(),getTableSchema( string $tableName ),hasColumn( string $tableName, $columnName ),hasTable( string $tableName ),setConfig( string $host, string $name = 'schema', DriverInterface $driver = null ).
Handling tables
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 ).
Selection request
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 ).
Request for execution
insertInto( string $tableName, array $columnNames ),values( array $rowValues ),update( string $tableName, array $row ),delete(),execute()Performs the insertion, modification and deletion of data.
Result(s) of the query
fetch(): arrayReturns the first result of the query,fetchAll(): arrayReturns all the results of the query,lists( string $columnName, string $key = null ): arrayReturns a list of the column passed in parameter.
Where
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 ).
Supported conditions (===, ==, !=, <>, <, <=, >, >=, like, ilike, not like, not ilike)
Where
whereGroup( \Closure $columnName ),orWhereGroup( \Closure $columnName ),notWhereGroup( \Closure $columnName ),orNotWhereGroup( \Closure $columnName ).
Where between
between( string $columnName, $min, $max ),orBetween( string $columnName, $min, $max ),notBetween( string $columnName, $min, $max ),orNotBetween( string $columnName, $min, $max ).
Where in
in( string $columnName, array $values ),orIn( string $columnName, array $values ),notIn( string $columnName, array $values ),orNotIn( string $columnName, array $values ).
Where isNull
isNull( string $columnName ),orIsNull( string $columnName ),isNotNull( string $columnName ),orIsNotNull( string $columnName ).
Where regex
regex( string $columnName, string $pattern ),orRegex( string $columnName, string $pattern ),notRegex( string $columnName, string $pattern ),orNotRegex( string $columnName, string $pattern ).
Usage
For examples of uses, refer to the user documentation.
License
This project is licensed under the MIT license.
soosyze/queryflatfile 适用场景与选型建议
soosyze/queryflatfile 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.06k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2018 年 02 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「nosql」 「database」 「php」 「library」 「db」 「composer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 soosyze/queryflatfile 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 soosyze/queryflatfile 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 soosyze/queryflatfile 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
The DreamFactory(tm) CouchDB Service.
Store your language lines in the database, yaml or other sources
The CodeIgniter Redis package
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Symfony lock Tarantool store
统计信息
- 总下载量: 1.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 11
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-12