Solved

Connect to MS-SQL server from Linux/PHP

Posted on 2016-10-12
8
84 Views
Last Modified: 2016-10-27
I'm migrating a website over to a LAMP stack from a windows machine. Everything is going smoothly except for all the PDO exceptions. The PDO was using the "sqlsrv" driver, however that driver is no longer found. (We are moving to a debian server, and I can't find the driver in the debian package repos).


Anyways I need to know how either where to find a linux build for the sqlsrv driver. Or an alternative driver that does support linux. Thanks.
0
Comment
Question by:rcimasi
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 41841180
Linux does not have an equivalent driver.  There is the old 'mssql' driver but it does not have all the features that 'sqlsrv' does.  This article https://www.experts-exchange.com/questions/27424576/Looking-for-examples-on-connecting-to-MS-SQL-Server-with-freetds-in-C.html is the best description I have for the process on Linux.
0
 
LVL 77

Expert Comment

by:arnold
ID: 41841181
On Linux freetds, which SQL server is being used, which Linux is are you using?
1
 
LVL 62

Expert Comment

by:gheist
ID: 41841507
... and long learning to not copy and paste DB connection strings around the application.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 47

Expert Comment

by:Vitor Montalvão
ID: 41841509
0
 

Author Comment

by:rcimasi
ID: 41842021
Thanks everybody, So far I see that mssql and JDBC are valid drivers. But how do I install then to be used in the PDO driver?


I'm using Debian Jessie with apache2.
0
 
LVL 47

Expert Comment

by:Vitor Montalvão
ID: 41842027
What stands for PDO?
0
 

Author Comment

by:rcimasi
ID: 41842127
PDO: PHP Datbase Object
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 41842316
There is some more 'info' on this page http://php.net/manual/en/ref.pdo-dblib.php .  The Microsoft ODBC driver for Linux has limited support.  Since it supports a current version of Ubuntu, you 'might' be able to get it to work on Debian.  https://msdn.microsoft.com/en-us/library/mt683457(v=sql.110).aspx  

In general however, there is no direct support for what you want to do.  You probably won't be able to get it to work as well on Linux as you did on Windows.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question