tomwright/extended-pdo
Composer 安装命令:
composer require tomwright/extended-pdo
包简介
An extension on the standard PDO library.
README 文档
README
Installation
composer install tomwright/extended-pdo
Connecting
ExtendedPDO implements the singleton design pattern using tomwright/singleton. For more information on how the following code works, see the documentation.
$db = ExtendedPDO::createConnection($dsn, $username, $password, 'my-main-db'); $db2 = ExtendedPDO::getInstance('my-main-db'); var_dump($db === $db2) // TRUE
Usage
// Returns an array of records $db->queryAll('SELECT * FROM users WHERE username = :username', [':username' => 'Tom']); // Returns the first record $db->queryRow('SELECT * FROM users WHERE username = :username LIMIT 1', [':username' => 'Tom']);
Query Return Types
You can set the return type of the dbQuery(), queryAll() and queryRow() methods using $db->setReturnType($x) where $x is the return type you'd like to use.
Available return types are as follows:
ExtendedPDO::RETURN_TYPE_OBJECT- Your results will be returned as objectsExtendedPDO::RETURN_TYPE_ASSOC- Your results will be returned as associative arraysExtendedPDO::RETURN_TYPE_STMT- The statement object will be returned directly
You can also set a return type of \PDO::FETCH_ASSOC for example and it will override any of the above. This makes all of the standard PDO fetch types usable.
Query Builder
ExtendedPDO also comes with it's own Query Builder.
tomwright/extended-pdo 适用场景与选型建议
tomwright/extended-pdo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 554 次下载、GitHub Stars 达 2, 最近一次更新时间为 2016 年 11 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 tomwright/extended-pdo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tomwright/extended-pdo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 554
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 2
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2016-11-10