Solved

Connect to MS-SQL server from Linux/PHP

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

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 76

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 45

Expert Comment

by:Vitor Montalvão
ID: 41841509
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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 45

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 82

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
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 …

708 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

20 Experts available now in Live!

Get 1:1 Help Now