Got error stating 'Couldn't locate driver named mssql'

Installation and environment issues, mainly on 1.x but there's some 2.x here too.

Moderators: dwhittle, Ian

Got error stating 'Couldn't locate driver named mssql'

Postby TinyGrasshopper » Mon Mar 07, 2011 7:11 pm

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.
TinyGrasshopper
Junior Member
 
Posts: 6
Joined: Fri Mar 04, 2011 12:23 am

Re: Got error stating 'Couldn't locate driver named mssql'

Postby halfer » Tue Mar 08, 2011 2:07 am

I don't know much about this, since I've never used MSSQL with PHP. However I'd guess that php_sqlsrv.dll won't make a difference here, since Doctrine only uses PDO modules. The module you'll end up using will +definitely+ have "pdo" in the filename.

Ah! Just read the PHP page for MSSQL - no longer included. Read the comments for how to get this working under PHP 5.3:

http://php.net/manual/en/ref.pdo-dblib.php

By the way, you may need to enable the necessary extension in your php.ini (if you have two of these - in both versions). Check the output of "php -m" at the command line to be sure.
halfer
Faithful Member
 
Posts: 10148
Joined: Mon Jan 30, 2006 1:16 pm
Location: West Midlands, UK

Re: Got error stating 'Couldn't locate driver named mssql'

Postby TinyGrasshopper » Thu Mar 10, 2011 7:41 pm

The link you sent reaffirms the position that I'm in. It says php_mssql.dll is no longer supported on PHP 5.3 and as such doesn't exist. Instead use the Microsoft supplied extension which is php_sqlsrv.dll.

From where I stand it sounds like there's no way to connect to mssql using Doctrine then, because Doctrine has to know that its being run on PHP 5.3 on Windows and that it shouldn't use the typical MSSQL Driver extension (php_mssql.dll) with it but it should instead use the Microsoft MSSQL Driver (php_sqlsrv.dll) and know how to do that.

Currently when I change to DSN to use sqlsrv as is specified in http://msdn.microsoft.com/en-us/library/cc296182.aspx to 'sqlsrv:host=localhost;dbname=jobeet', it just says "Unknown driver sqlsrv".

The only 'easy' solution I've found so far was to stick with PHP 5.2. Does anyone know if Doctrine 2 in Symfony 2 fixes this and has support for the Microsoft SQL Driver?
TinyGrasshopper
Junior Member
 
Posts: 6
Joined: Fri Mar 04, 2011 12:23 am

Re: Got error stating 'Couldn't locate driver named mssql'

Postby halfer » Wed Mar 16, 2011 12:26 am

I've only done a bit of MSSQL with PHP, and that was with an old version of Propel that did not use PDO. So I can't offer any expert advice here...

But, I'd be very surprised if PDO did not work with MSSQL. If you are right that php_mssql is no longer supported, it may be because that module is not based on PDO, and that you need to use php_pdo_mssql.dll. But I am only guessing here. This googled link looks promising:

http://forums.iis.net/t/1164419.aspx
halfer
Faithful Member
 
Posts: 10148
Joined: Mon Jan 30, 2006 1:16 pm
Location: West Midlands, UK

Re: Got error stating 'Couldn't locate driver named mssql'

Postby pluk77 » Fri Apr 08, 2011 11:18 am

Not entirely sure if this helps, but there is a white-paper written about how to use PDO and MS SQL using the MSSQL 2 driver:

The article: http://www.phparch.com/2010/11/got-mssql-check-out-our-whitepaper/

and the actual whitepaper: http://beta.phparch.com/wp-content/uploads/2010/11/PDO__MSSQLServer.pdf

I have not tried using Symfony 1.4 / Doctrine on MSSQL but am definitely interested in knowing if this works well and if I could potentially migration from MySQL to MSSQL if I need to.
Marcel
User avatar
pluk77
Junior Member
 
Posts: 22
Joined: Thu Apr 01, 2010 2:39 pm
Location: Cape Town

Re: Got error stating 'Couldn't locate driver named mssql'

Postby Gendoo » Tue Oct 25, 2011 8:49 am

Tue, 09 Jun 2009 20:16:05 -0700
I used to be able to run my Symfony 1.2.4 application on Virtual Box
2.0 with Ubuntu 8.1
I upgraded to Virtual Box 2.2 and Ubuntu 9.04. I get the following
error: Couldn't locate driver named mysql. How is it possible to fix?
Gendoo
Junior Member
 
Posts: 1
Joined: Tue Oct 25, 2011 8:45 am


Return to Installation and setup

Who is online

Users browsing this forum: No registered users and 0 guests