aldisaglobal/mysql-db
Composer 安装命令:
composer require aldisaglobal/mysql-db
包简介
A Simple Iterateable MySQL DB Query Object
README 文档
README
Vendor: aldisaglobal
Package: mysql-db
Author: Abid
Version: 0.2
Connection Parameters
Make available the following Connection parameters:
MYSQL_HOSTthe URI for the MySQL serverMYSQL_USERthe usernameMYSQL_PASSthe passwordMYSQL_DBthe database
Option 1: As Environment Variables
Place connection params in $_ENV superglobal Optional: You can use the \vlucas\dotenv package with a .env file to populate $_ENV variables
Option 2: As Constants
You can define these constants in a settings file
Option 3: As an Array
You can create and pass a parameters array to the create method
$params = array('MYSQL_HOST'=>"hostname", ...)
Instantiate a Database Object
Use the static create method to get the DB object:
use AldisaGlobal\MySQL\DB;
$db = DB:create([$params]);
Execute queries on the Database Object
$db->query("...mysql statement...");
Iterate SELECT Queries
foreach ($db as $row) {
echo $row->field;
}
The full Object API
\AldisaGlobal\MySQL\DB::create([$params]) - returns object with connection
$db->init() - closes any open result
$db->escape($str) - returns escaped string
$db->getResponse()- returns last server response
$db->getError() - returns error string from last query
$db->getErrno()- returns errno from last query
$db->hasError() - true if last query had an error
$db->query($sql [, $buffered=true])- executes query, pass false as second arg for unbuffered query
$db->hasResult() - whether query returned a result
$db->getInsertID()- returns InsertID of last insert query
$db->getRow()- returns the current row
$db->getNextRow([$mode = "object"])- returns next row of result as object [pass "array" to get back an assoc array]
$db->getFirstRow([$mode = "object"]) - returns first row of result as object
$db->getRowNum($num [, $mode = "object"]) - returns row at $num index
$db->getNumFields()- returns number of columns in result row
$db->getFields() - returns array of column names
$db->getNumRows() - returns total number of rows in result [not accurate for unbuffered queries]
aldisaglobal/mysql-db 适用场景与选型建议
aldisaglobal/mysql-db 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 28 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 10 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 aldisaglobal/mysql-db 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aldisaglobal/mysql-db 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 28
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-26