10

I am trying to use PDO to connect to a MS SQL Server. I have tried using this

$db = new PDO("sqlsrv:server=server;database=databaseName", "username", "password");

I was reading that sqlsrv is no longer supported. I tried using dblib but that is not working.

I wanted to use PDO because it is supposed to work with various databases but I cannot seem to get it to work with MS SQL.

What is the best way to use PDO with SQL Server on Ubuntu?

Any help would be great.

Thanks

1

1 Answer 1

19

I figured it out. I guess I forgot that I never installed the SQL/Sybase drivers on this server.

I installed it:

sudo apt-get install php5-sybase

Now I can use:

$db = new PDO("dblib:host=sever;dbname=dbname", "username", "password");

It's working good now.

1
  • for us (ubuntu 16.04, with PHP7) it is: apt-get install php-sybase Commented Sep 13, 2018 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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