restu/dbhelper
Composer 安装命令:
composer require restu/dbhelper
包简介
package library for help you to use database
关键字:
README 文档
README
Halo, mohon untuk di coba dbhelper php yang saya buat, semoga bisa membantu dalam kode kamu.
~Terima Kasih
Cara Pakai
Lihat Index.php untuk implementasi
1. Install & Config
1.1 copy or clone dbhelper ke app kamu.
//if use composer composer require restu/dbhelper
1.2 config koneksi database di folder /config file db.json.
di folder /dbhelper/config file db.json.
2. Buat Table Class
buat table class sesuai database / tabel kamu didalam folder /dbhelper/dbclass
//table class must use namespace dbhelper & extends from _tbl namespace dbhelper; class Tbl extends _tbl{ protected $_tbl = 'tbl'; protected $_pk = 'id'; //must have primary key //define fields protected $_fields = [ 'id' => null ,'namatest' => null ,"info" => null ]; }
3. required _dbloader.php or autoload vendor composer
require _dbloader.php atau autoload vendor composer di atas dokumen php kamu agar bantuan database / tabel bisa di panggil
require ("dbhelper/_dbloader.php"); //if use composer require_once __DIR__ . '/vendor/autoload.php'; //your folder app need this -- Your App Folder --- dbhelper --config --db.json //your connection to database --dbclass --Tbl.php //your tbl class
4. Intansiasi Tabel
Instansiasi tabel yang diperlukan dengan new dbhelper\Tbl()
//with new dbhelper\; $tbl = new dbhelper\Tbl();
5. Good luck & Have fun with your app
5.1 Create
5.1.1 Insert 1
$tbl->insert(associativeArray)
$argsInsert = [ "namatest" => "nilai" ,"info" => "nilai record yang di insert" ]; $tbl -> insert($argsInsert);
5.1.2 Insert 2
one by one set value field then call $tbl -> new();
$tbl -> setValue("namatest", "nilai" ); //field name, value record $tbl -> setValue("info", "nilai record yang di insert"); $tbl -> new();
5.2 Update
5.2.1 Update 1
by primary keys value
$argsUpdate = [ "namatest" => "nilai Update" ,"info" => "nilai record yang di update edit" ]; $tbl -> update('1',$argsUpdate);
5.2.2 Update 2
by filter
$argsWhereFilter = [ "namatest" => "nilai Update" ]; $argsUpdate = [ "namatest" => "nilai Update" ,"info" => "nilai record yang di update edit" ]; $tbl -> updateBy($argsWhereFilter,$argsUpdate);
5.3 Delete
5.3.1 Delete 1
by primary keys value
$tbl -> delete('1');
5.3.2 Delete 2
by filter
$argsDeleteFilter = [ "namatest" => "nilaid" ]; $tbl -> deleteBy($argsDeleteFilter);
5.4 Get
Get only get one data and add to fields table
5.4.1 Get 1
get by keys arrays by primary key
$record = $tbl -> get(['5']);
5.4.2 Get 2
if you have other unique value can use getBy
$tbl -> getBy('field','value'); $record = $tbl -> getBy('id','4');
5.5 Query
even you can query many data
$records = $tbl -> query("id,namatest,info",[ "namatest='nilai'" //," and " //,"id = '5'" ]);
6. Other Feature
6.1 Get Next Number
$number = $tbl -> nextno("id"); echo $number; $number = $tbl -> nextno("id", ["namatest='nilaidf'"]); echo $number;
6.2 encrypt & verify value field
$tbl -> encrypt("namatest", "realvalue"); echo $tbl -> value("namatest"); //verify value field will return 1 if verified $isVerify = $tbl -> verify("namatest", "realvalue"); echo $isVerify;
6.3 time
$time = $tbl -> timeNow(); echo $time;
6.4 setvalue & unset field
$tbl->setValue("infodsf",7); $tbl->unset(["infodsf"]); echo $tbl->value("infodsf");
restu/dbhelper 适用场景与选型建议
restu/dbhelper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 09 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「mysql」 「pdo」 「DB Helper」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 restu/dbhelper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 restu/dbhelper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 restu/dbhelper 相关的其它包
同方向 / 同关键字的高下载量 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
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-19