4

I want to connect to sql server database which is placed on a remote server while my php code has been installed on an ubuntu server. I found that it needs to install sqlsrv driver or mssql driver before connecting. How can I install the requirement(s) in advanced?

2
  • What's the interface your PHP application uses for connection? PDO, ODBC, mssql_*() functions directly, any other? Jul 26 '15 at 7:12
  • I'm using PDO driver Jul 26 '15 at 12:02
1

Install PHP extension in OS: apt-get install php5-sybase, restart Apache or PHP-FPM (depending on your SAPI). Make sure the newly installed PDO driver is loaded (should be enabled automatically, check for output line php5_invoke: Enable module pdo_dblib for [your SAPI here]). This will also install all dependencies. Now you can use mssql: DSNs in PDO, as presented in PHP manual.

There's another PDO driver for MSSQL, but it only works under Windows.

You can also use PDO with ODBC.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.