Solved

Connect to MS-SQL server from Linux/PHP

Posted on 2016-10-12
8
81 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 61

Expert Comment

by:gheist
ID: 41841507
... and long learning to not copy and paste DB connection strings around the application.
0
 
LVL 46

Expert Comment

by:Vitor Montalvão
ID: 41841509
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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 46

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now