croak-dbmanagement/dbmanagement
Composer 安装命令:
composer require croak-dbmanagement/dbmanagement
包简介
a set of php objects and interfaces for a simple use of databases using PDO
README 文档
README
php classes to manage generic databases with pdo
With DbManagement, you just have to implements the DbManagement interface, extends the DbManagementObject and define queries according to the database type and then building tables or queryng is really simple.
use DbManagement thanks to composer : composer require croak-dbmanagement/dbmanagement
The DbManagement interface has to be implemented to deal with different kind of databases and then different syntaxes. The package https://github.com/20centcroak/SqliteDbManagement gives an implementation to deal with sqlite. If you use sqlite, use this package which calls the DbManagement package :
composer require croak-sqlite-dbmanagement/sqlite-dbmanagement
The DbManamgementObject needs the table fields definition. This is done thanks to 4 constant arrays that should be created in the class that extends DbManagementObject:
- KEYS[key=>value] defines the field names of the table. The field names are all the values of the array. Values are string.
- KEY_TYPES[key=>type] define the field types associated to the field name thanks to the same key as the array KEYS. It may be one of the function used by php to test variable type (is_string, is_numeric, is_int, is_float, ...). and is then not dependent on the Database syntax. Types are string
- KEY_REQUIRED[key=>required] define wich fields are required when adding a record in the database. the "required" value is associated with the field name thanks to the same key as the array KEYS. Required are boolean.
- KEY_UNIQUE[key=>unique] define wich fields have to be unique when adding a record in the database. the "unique" value is associated with the field name thanks to the same key as the array KEYS. Unique are boolean.
abstract setter methods of DbManamgementObject should be filled in to return these constants
here is an example:
` use Croak\DbManagement\Exceptions\IotException;
use Croak\DbManagement\DbManagementObject;
class Measure extends DbManagementObject{
const KEYS = array(
"type"=>"type",
"unit"=>"unit",
"value"=>"value",
"flag"=>"flag",
"deviceSn"=>"id_device",
"date"=>"created"
);
const KEY_TYPES = array(
"type"=>"is_string",
"unit"=>"is_string",
"value"=>"is_float",
"flag"=>"is_string",
"deviceSn"=>"is_string",
"date"=>"is_string"
);
const KEY_REQUIRED = array(
"type"=>true,
"unit"=>true,
"value"=>true,
"flag"=>false,
"deviceSn"=>true,
"date"=>true
);
const KEY_UNIQUE = array(
"type"=>false,
"unit"=>false,
"value"=>false,
"flag"=>false,
"deviceSn"=>false,
"date"=>false
);
public function getKeys(){
return constant("self::KEYS");
}
public function getTypes(){
return constant("self::KEY_TYPES");
}
public function getRequiredKeys(){
return constant("self::KEY_REQUIRED");
}
public function getUniqueKeys(){
return constant("self::KEY_UNIQUE");
}
} `
It is as easy as this!
For querying with the GET verb, use the following keywords:
- [fieldName]-up pour trier les données par ordre ascendant sur le champ [fieldName]
- [fieldName]-down pour trier les données par ordre descendant sur le champ [fieldName]
- [fieldName]-min=XXX pour sélectionner les données telles que [fieldName]>=XXX
- [fieldName]-max=XXX pour sélectionner les données telles que [fieldName]<=XXX
- [fieldName]=XXX pour sélectionner les données telles que [fieldName]=XXX
Let assume that the route localhost:8080/measures is defined in your app and the fields named "value" and "flag" are defined in the database table, here is an example of a GET request :
localhost:8080/measures?value-min=12&value-up&flag-down
croak-dbmanagement/dbmanagement 适用场景与选型建议
croak-dbmanagement/dbmanagement 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 51 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 10 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「pdo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 croak-dbmanagement/dbmanagement 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 croak-dbmanagement/dbmanagement 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 croak-dbmanagement/dbmanagement 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
A PSR-7 compatible library for making CRUD API endpoints
PHP module for MySql database
VV database abstraction layer with query builder and DB structure models
统计信息
- 总下载量: 51
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-12