Native SQL 2005 driver for PHP under Linux/Unix


  • Hello!

    I'm looking a native driver for SQL 2005 running under Linux/Unix!

    Or Is accessible anywhere source code of the existing driver for php?

    I tried FreeTDS, but it has some bugs and has no support.


    Is there any good solution for this problem?


    16 octombrie 2007 12:21


Toate mesajele

  • There currently is no native driver for SQL 2005 from Microsoft for Linux/Unix.  The existing Microsoft PHP driver is not open source, and is Windows only.  Sadly, there is currently no good solution to the problem of using native access for SQL Server from *NIX.  However, SOAP does provide a simple mechanism for communicating with SQL Server from *NIX -- but it is not a native access method.



    Hope that helps,




    16 octombrie 2007 18:42
  • As John mentioned, there are no Microsoft supported native access providers on Unix/Linux.  However, we are always looking for customer feedback on what is useful to them for accessing SQL Server.


    I might suggest looking at PDO.  I know PDO has a number of good drivers, and there might be support for a Unix ODBC driver in the ODBC PDO driver.  Also, I know that PDO supports the FreeTDS driver, which as you mention is incomplete, but it currently the only solution I know of.




    17 octombrie 2007 16:04
  • PDO ODBC (and PHP iteself) needs some updating before it can properly support a lot of the 2005 and above data types including XML, MAX and National (Unicode) types. I implemented the Easysoft ODBC Driver for Linux with native ODBC calls in my PHP code (i.e. ripped out PDO) and it worked very well. All the data types I cared about were supported. I ended up working through three bugs with Easysoft in the XML, National and MAX data type handling and had to spend some time getting my ODBC configuraiton setup, but it is the only full-feature solution came across. C'mon Microsoft, a PHP driver that leverages the Native Client ODBC driver is nice to have, but you missed the majority of the PHP community. If your target was to make it easy to access SQL Server from PHP I would have to say that a claim of success must be deferred. If you were angling to get new Windows PHP development onto IIS and Windows, then bravo!
    5 noiembrie 2009 21:26
  • There is now an ODBC driver for linux available here:

    It is 64 bit only, and targets RH5.  As you noted, you can use PDO_ODBC to project this into the PHP layer.  Note that PHP is by default 32 bit, and you would need a 64 bit build of PHP to work with this.


    Hope that helps!


    This post is provided 'as is' and confers no express or implied warranties or rights.
    1 decembrie 2011 22:57
  • I'm happy to see that this driver exists now, but does anyone have any idea how to get it to recognize a named instance? It "appears" to be working with the default instance on 2 different servers we have here, but specifying a different instance using the standard naming convention <server>\<instance> just gets a long wait and a timeout. 

    Using the specific port for the instance seems like the obvious choice, however when I do that - it still seems to only connect to the default instance somehow...

    All I'm going by here is the fact that when pointed to port 1241 (port of a named instance here) it will not accept any server logins setup on that named instance, but a test login I created on the default instance is allowed to login, and then of course I get the error about not being able to open that database since it  doesn't actually exist on that instance!

    Thanks :)

    4 aprilie 2012 20:04
  • Just kept guessing until I got it to work. Even though other documentation I was reading showed the DSN entry in odbc.ini with the Port entry for the named instance listed on it's own line separate from the Server entry like so:

    Server =

    Port = 1348

    and listing the SQL Server instance in the Server entry like so got me nowhere:

    Server =\INSTANCE

    Port = 1348

    adding the instance and the port in the Server entry seems to work:

    Server =\INSTANCE,1348


    9 aprilie 2012 19:35
  • please could you refer the belo link.

    17 aprilie 2012 12:35