logo
Ask your Symfony questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$10
Can't get Doctrine to connect to MSSQL Server 2008 on Windows

Hello,

I'm trying to follow the Practical symfony 'jobeet' tutorial at http://www.symfony-project.org/jobeet/1_4/Doctrine/en/ except with MS SQL Server 2008 R2 and IIS on Windows Server 2008 R2 instead of on MySQL and Apache. I'm getting a problem with Doctrine connecting to my MSSQL Server which is on the same machine as symfony, IIS and PHP. When I attempt to run the doctrine command I get

c:\jobeet>php symfony doctrine:insert-sql
>> doctrine creating tables


Couldn't locate driver named mssql



My databases.yml contains the following:
all:
doctrine:
class: sfDoctrineDatabase
param:
dsn: 'mssql:host=localhost;dbname=jobeet'
username: sa
password: my_sa_password


I have been following the instructions at the More With Symfony book at http://www.symfony-project.org/more-wit ... nd-Symfony in order to get symfony installed and running on Windows with IIS. To that end, I installed PHP using the Web Platform Installer from http://www.microsoft.com/web/downloads/platform.aspx as was detailed in More with Symfony. I also installed the Microsoft SQL Driver 2.0 for PHP v5.3 in IIS, thinking that was needed.

So when I check my PHP installation at C:\Program Files (x86)\PHP\v5.3 that WPI installed, in the ext folder there's a php_sqlsrv.dll, php_pdo_sqlsrv.dll, php_pdo_odbc.dll but no php_mssql.dll or php_pdo_mssql.dll. Is there supposed to be a php_mssql.dll? What package do I need to install to get that support? How do I install it?

I'm assuming php_sqlsrv.dll and php_pdo_sqlsrv.dll are the Microsoft SQL Driver 2.0 for PHP v5.3 in IIS, but when I try to change the dsn in databases.yml to either 'sqlsrv:host=localhost;dbname=jobeet' or 'pdo_sqlsrv:host=localhost;dbname=jobeet', I get the error 'Unknown driver sqlsrv' and 'Unknown driver pdo_sqlsrv' I also tried adding an odbc connection and using 'odbc:host=localhost;dbname=jobeet' and still got a similar error. What is the correct syntax for the the dsn for the different databases? Why doesn't Doctrine support the Microsoft SQL Driver for PHP? Which package do I need to install to get dll needed for the Doctrine support for MSSQL?

The only mention of the MSSQL drivers in the More with Symfony book is the following. The tutorial doesn't actually use the drivers, it uses the SQLite driver.

Planned Extension for this Tutorial
A supplemental section of this chapter is in the works and will be released on the symfony
project web site shortly after the publication of this book. It covers the connection to MS
SQL Server via PDO, something Microsoft is planning improvements for soon.
[PHP_PDO_MSSQL]
extension=php_pdo_mssql.dll
Currently, the best performance in code execution is obtained by the Microsoft native SQL
Server driver for PHP 5, an open-source driver available on Windows and currently
available in version 1.1. This is implemented as a new PHP extension DLL:
[PHP_SQLSRV]
extension=php_sqlsrv.dll
It is possible to use either Microsoft SQL Server 2005 or 2008 for the database. The planned
tutorial extension will cover the usage of the edition that is available for free: SQL Server
Express.

It doesn't look like that Planned Extension was ever updated to be part of the tutorial.

This question has been answered.

Christopher Yee Mon | 03/07/11 at 5:04pm Edit


(2) Responses

See a threaded view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    03/18/11
    1:38am
    Loban Rahman says:

    I found this blog post with some info regarding getting Symfony 1.4 and Doctrine 1.2 working with MSSQL Server 2008 and using PHP 5.2

    http://tecnofuenteabierta.blogspot.com/2010/12/running-symfony-14-with-ms-sql-server.html

  • avatar
    Last edited:
    03/07/11
    10:01pm
    Loban Rahman says:

    The site suggest sticking to PHP 5.2 to use the php_mssql and php_pdo_mssql drivers, and to use the cp1252 charset instead of UTF-8.

This question has expired.





Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.