php-kit/ext-pdo 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

php-kit/ext-pdo

Composer 安装命令:

composer require php-kit/ext-pdo

包简介

An extension to the standard PHP PDO API

README 文档

README

Ext-PDO is a lightweight extension to PHP's native PDO API that ships sensible defaults for the most popular database drivers and adds a few helper methods to streamline everyday database work.

Features

  • Driver-aware factoryExtPDO::create() instantiates the appropriate subclass for MySQL, PostgreSQL, SQLite or SQL Server, so you only need to provide driver-agnostic connection settings.
  • Safer transaction handling – transparent tracking of the transaction depth prevents accidental commits when you are using nested transactions and only calls through to PDO when the outermost transaction succeeds.
  • Convenience helpersexec(), select() and get() accept bound parameters directly and return useful values without requiring boilerplate prepared-statement code.
  • Optimized connection defaults – the bundled driver subclasses configure error modes, fetch modes, timeouts and driver-specific options like ANSI quotes for MySQL so you do not have to remember to tune them yourself.
  • Environment-driven configuration (optional) – the Connection and Connections helpers can bootstrap connections from environment variables or custom factories, making it easy to centralize connection management in larger applications.

Benefits

  • Reduce boilerplate when running parameterized queries and fetching results thanks to helper methods.
  • Gain predictable error handling and data fetching behaviour from the sensible defaults applied to each driver.
  • Safely compose higher-level data access routines that require nested transactions.
  • Standardize how connections are created across environments while keeping the flexibility to override options when necessary.

Installation

Install the package via Composer:

composer require php-kit/ext-pdo

Usage

Creating a connection directly

use PhpKit\ExtPDO\ExtPDO;

$pdo = ExtPDO::create('mysql', [
    'host' => '127.0.0.1',
    'database' => 'app',
    'username' => 'app_user',
    'password' => 'secret',
    'charset' => 'utf8mb4',
]);

$pdo->beginTransaction();

try {
    // Run parameterized statements without manual statement preparation.
    $pdo->exec('INSERT INTO posts (title, body) VALUES (?, ?)', ['Hello', 'First post']);

    // Quickly fetch a single value.
    $postCount = $pdo->get('SELECT COUNT(*) FROM posts');

    // Or work with a full result set.
    $statement = $pdo->select('SELECT * FROM posts WHERE id = ?', [1]);
    $post = $statement->fetch();

    $pdo->commit();
} catch (Throwable $e) {
    $pdo->rollBack();
    throw $e;
}

You can override any PDO options at creation time by passing an $optionsOverride array as the third argument to ExtPDO::create().

Loading connections from the environment

use PhpKit\ExtPDO\Connections;

$connections = new Connections();

// Reads DB_DRIVER, DB_HOST, DB_DATABASE, DB_USERNAME, etc. from the environment.
$default = $connections->get();

// Register additional named connections when needed.
$connections->register('reporting', function () {
    // Build and return a Connection instance here.
});

Set environment variables such as DB_DRIVER, DB_HOST, DB_DATABASE, DB_USERNAME, and DB_PASSWORD (or their NAME_-prefixed variants for named connections) to let Ext-PDO configure the connection automatically.

Copyright © 2015 Impactwave, Lda.

php-kit/ext-pdo 适用场景与选型建议

php-kit/ext-pdo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 34.23k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2015 年 09 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 php-kit/ext-pdo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 php-kit/ext-pdo 我们能提供哪些服务?
定制开发 / 二次开发

基于 php-kit/ext-pdo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 34.23k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 17
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-09