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.

Sign up to request clarification or add additional context in comments.

1 Comment

for us (ubuntu 16.04, with PHP7) it is: apt-get install php-sybase

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.