Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Connect to MS-SQL server from Linux/PHP

Posted on 2016-10-12
8
88 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 48

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 48

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Fine Tune your automatic Updates for Ubuntu / Debian
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

792 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