I am trying to use Doctrine 2 (for Symfony 2) to connect to MSSQLServer from a linux machine.
I have installed pdo_dblib (PDO Driver for FreeTDS/Sybase DB-lib) and am able to connect to the db server via tsql on the command line and from the php cli also. Thus I know this is working.
In my Symfony/app/config/parameters.ini file I had specified database_driver="pdo_sqlsrv" as the database driver (as I read that this would be handled by db_lib
) but when trying to run a create database command (using the command php app/console doctrine:database:create
) I am getting the error:
Could not create database for connection named could not find driver
I then changed the driver to database_driver="pdo_dblib"
and I am now getting the error:
[Doctrine\DBAL\DBALException]
The given 'driver' pdo_dblib is unknown, Doctrine currently supports only the following drivers: pdo_mysql, pdo_sqlite, pdo_pgsql, pdo_oci, oci8, ibm_db2, pdo_ibm, pdo_sqlsrv
So it seems that to connect to MSSQL my only option is pdo_sqlsrv
, so I went to install this. However, I have just discovered here, that
The PDO_SQLSRV extension is only compatible with PHP running on Windows.
Thus the driver supported by doctrine and those available to use on linux seem to be mutually exlusive. From searching I haven't found any instances of this issue being solved thus far (One guy marked the issue as solved, but when I read the thread he had simply moved his dev env to a windows box... not exactly what I had in mind!).
Under linux (at least Debian based distros), php needs the package
php5-sybase
that brings support for Sybase and MSSql.If you are using a debian based distribution you will want to do
And
should give you
dblib
is actually the one we needNow to be able to use this driver with Doctrine, this post: Doctrine 2 - How to add custom DBAL driver? helped me to find the answer.
The OP suggests to use this bundle on git that makes things work together.