2017 © Pedro Peláez
 

library pdodblib-bundle

PDO DBlib Driver for Symfony

image

wiz/pdodblib-bundle

PDO DBlib Driver for Symfony

  • Monday, February 29, 2016
  • by wizmacau
  • Repository
  • 1 Watchers
  • 0 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 38 Forks
  • 0 Open issues
  • 1 Versions
  • 4 % Grown

The README.md

PDODblibBundle

This PDO DBLib bundle adds support for Microsoft SQL Server Doctrine 2. Take it with a grain of salt: Many of the Doctrine unit tests fail when using this driver. PHP's PDO_DBLIB driver does not support many of the features within doctrine. There is a patch in the PHP repo to add transaction and lastInsertId support, but this package has some minor work arounds., (*1)

This bundle requires the following: * pdo_dblib * FreeTDS, (*2)

FreeTDS configuration

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

[mssql_freetds]
    host = 192.168.1.1
    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:, (*4)

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

And in your autoload.php register the new bundle:, (*5)

$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:, (*6)

  • Install FreeTDS and configure a server connection, (*7)

    • Verify with ./tsql -S mssql_freetds -U yourusername -P yourpassword
  • Install the PHP DBLib extension -- verify with PHP script containing, (*8)

    • Verify $pdo = new PDO('dblib:host=mssql_freetds;dbname=yourdb', 'yourusername', 'yourpassword');
  • Install and configure the PDODblibBundle, (*9)

    • 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., (*10)

http://svn.php.net/viewvc/php/php-src/trunk/ext/pdo_dblib/dblib_driver.c?view=log, (*11)

See: Revision 300647 - lastInsertId Revision 300628 - transaction support, (*12)

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:, (*13)

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:, (*14)

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

The Versions

29/02 2016

dev-master

9999999-dev

PDO DBlib Driver for Symfony

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

symfony pdo dblib