hovjacky/nosql
Composer 安装命令:
composer require hovjacky/nosql
包简介
PHP Client for Elasticsearch (MongoDB and Cassandra are almost finished) - easy and unified queries
关键字:
README 文档
README
This package creates unified API for some NoSQL databases (at the time only Elasticsearch, MongoDB and Cassandra need to be finished).
Installation
The recommended way is via Composer:
composer require hovjacky/nosql
It requires PHP version 7.0 and higher.
Usage
Connection parameters (host, port, index) have to be passed as an array to the constructor of
ElasticsearchClient.
The following methods are supported:
- insert - array
$data - bulkInsert - array
$data - get - int
$id - update - int
$id, array$data - delete - int
$id - deleteAll
- findBy - array
$params- details described below.
All have table as first parameter (in Elasticsearch it is the type name).
####Method findBy Method findBy can be used for search. It supports quite a wide range of parameters (you can find comparison with SQL in parentheses):
- fields - array of fields user wants to retrieve (
SELECT id, name FROM) - limit - max. number of results (
LIMIT 10) - offset - can only be used with limit (
LIMIT 10, 10) - count - only get number of results
- orderBy - array of fields to order by, e.g.
['id', 'name'], descendant order is marked by lowercase desc -['id desc', 'name'](ORDER BY id DESC, name) - groupBy - array of fields to group by, e.g.
['id', 'name'](GROUP BY id, name)- Elasticsearch only:
- groupByScript - instead of a field name,
groupBycan contain the wordscriptandgroupByScriptcan then contain an elasticsearch script (https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html) - groupInternalOrderBy - array of fields to group by content inside each bucket (no SQL equivalent)
- groupByScript - instead of a field name,
- Elasticsearch only:
- aggregation - an associative array, keys are aggregation functions like max, min, avg, etc.
and values are names of fields the aggregations should apply to, e.g.
['min' => ['id', 'age'], 'avg' => ['age']](SELECT MIN(id), MIN(age), AVG(age) FROM) - where - an associative array, keys are conditions with placeholders (?) and values are values.
Conditions accept operators =, !=, >, <, >=, <=, LIKE, IS NULL, IS NOT NULL, CROSS FIELDS.
- LIKE - the value should contain % (the same as in SQL)
- = - the value can be an array, e.g.
['id = ?' => [1, 3, 7]](id IN (1, 3, 7)) - IS NULL, IS NOT NULL - Elasticsearch only
- CROSS FIELDS - searching string in multiple fields, e.g. name
John Smithin fieldsfirstnameandsurname. Syntax is"firstname,surname CROSS FIELDS ?" => "John Smith"
hovjacky/nosql 适用场景与选型建议
hovjacky/nosql 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19.18k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 02 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「nosql」 「elasticsearch」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 hovjacky/nosql 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hovjacky/nosql 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 hovjacky/nosql 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The DreamFactory(tm) CouchDB Service.
The CodeIgniter Redis package
simple api library.
Symfony lock Tarantool store
Symfony bundle for Elasticsearch integration with round-robin load balancing
Lucinda Framework 4.0: High performance, component-based PHP application skeleton
统计信息
- 总下载量: 19.18k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-14