leaseweb/doctrine-pdo-dblib 问题修复 & 功能扩展

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

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

leaseweb/doctrine-pdo-dblib

最新稳定版本:1.1.0

Composer 安装命令:

composer require leaseweb/doctrine-pdo-dblib

包简介

Library for support of the pdo_dblib (MSSQL) driver in Doctrine

README 文档

README

This repository is no longer being actively maintained. We encourage you to not use this code. If you rely on this code you might want to fork the repository to keep your systems from breaking, if we remove this repository in the future.

LswDoctrinePdoDblib

Doctrine 2 does support any method of connecting to SQL Server on a Linux box. Here's a simple driver that supports PDO DBlib. Many tests fail, but most are related to shortcomings of the PDODBlib driver. There is a patch in the PHP repo to add transaction and lastInsertId support, but this package has some minor work arounds.

This bundle requires the following:

  • pdo_dblib
  • FreeTDS

FreeTDS configuration

DBLib requires FreeTDS. We can't go into detail about configuring FreeTDS, but the connection configured should look something like following:

[mssql_freetds] host = 172.30.252.25 port = 1433 tds version = 8.0 client charset = UTF-8 text size = 20971520 

Setting up bundle in Symfony

In your Symfony2 project, modify your config.yml as follows to use the DBlib bundle and the server setup under FreeTDS:

# Doctrine Configuration doctrine: dbal: driver_class: Lsw\DoctrinePdoDblib\Doctrine\DBAL\Driver\PDODblib\Driver host: mssql_freetds 

And in your autoload.php register the new bundle:

$loader->registerNamespaces(array( 'PDODblib' => __DIR__ . '/../vendor/bundles', ));

Putting everything together

Getting everything together wasn't easy. You need to complete the following steps, checking each installation is successful by connecting with the appropriate tools:

  • Install FreeTDS and configure a server connection
    • Verify with ./tsql -S mssql_freetds -U yourusername -P yourpassword
  • Install the PHP DBLib extension -- verify with PHP script containing
    • Verify $pdo = new PDO('dblib:host=mssql_freetds;dbname=yourdb', 'yourusername', 'yourpassword');
  • Install and configure the PDODblibBundle
    • Verify Some kind of SQL against your database

FYI - PHP pdo_dblib patch

You can find a patch for some of the short-comings of pdo_dblib on SVN.

http://svn.php.net/viewvc/php/php-src/trunk/ext/pdo_dblib/dblib_driver.c?view=log

See: Revision 300647 - lastInsertId Revision 300628 - transaction support

FYI - Doctrine Test Suite

Doctrine2's test suite does not allow you to add database drivers on the fly. If you want to test this package, modify Doctrine/DBAL/Driver/DriverManager::$_driverMap as follows:

final class DriverManager { private static $_driverMap = array( /* ... snip ... */ 'pdo_dblib' => 'Doctrine\DBAL\Driver\PDODblib\Driver', ); }

FYI - Generating Entities from database

It's possible, but not easy. Here's what I did:

  • Map any non-compatible column types to string
  • Hack the Doctrine core to skip any tables without primary keys

leaseweb/doctrine-pdo-dblib 适用场景与选型建议

leaseweb/doctrine-pdo-dblib 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 556.95k 次下载、GitHub Stars 达 58, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「doctrine」 「pdo」 「mssql」 「dblib」 「pdo_dblib」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 leaseweb/doctrine-pdo-dblib 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 556.95k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 61
  • 点击次数: 26
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 58
  • Watchers: 17
  • Forks: 39
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04