Doctrine2: Connecting DBAL to Sql-Server

Connecting to MSSQL using Doctrine2 on Unix

I'm currently developing a project that uses Doctrine2 with PHP on an Ubuntu server (x64). It was required to retrieve data from the MSSQL server, which is executed externally.

Problem

Doctrine2 does not support driver pdo_dblib

, support is not supported sqlsrv

on unix-like machines ( sqlsrv

Windows only). Considering that Doctrine simply does not have built-in support for MSSQL servers on Unix machines.

Decision

These are the solutions I've tried without success.

1. Write your own framework for pdo_dblib

and integrate into the doctrineDBAL

I couldn't figure out how to write my own driver, framework, and schema for doctrines DBAL

, and didn't find anything helpful in my docs or on Google.

Actual question

Is there any support for MSSQL servers running Doctrine 2 without using Symfony or other third party code ?

+3


source to share


1 answer


Your original solution isn't really that hard. I ran into this problem while trying to connect to SQL Server using ODBC, which is one option for linux hosts and the only change I needed was to this file .

If you update this function and use a valid ODBC connection string instead, it will work fine. Of course, the Doctrine folks have not been able to simplify this feature, so you either have to resort to editing your library or copy / paste the entire SQL Server driver code.



However, support for SQL Server with ODBC is somewhat poor. For example, I ran into an issue where exceptions are thrown if you use bound parameters inside a subquery. Even though it works fine with the official Microsoft driver, which itself is ODBC based. Go figure. If possible, copy your data to a more Linux-friendly database and work with it there.

+1


source







All Articles