Git Product home page Git Product logo

pdodblibbundle's Introduction

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.

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 = 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:

# Doctrine Configuration
doctrine:
    dbal:
        driver_class:   PDODblibBundle\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:

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

pdodblibbundle's People

Contributors

arnolanglade avatar dermanomann avatar mabuzagu avatar trooney avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.