简体   繁体   中英

PHP PDO to MS SQL Server on Ubuntu Server

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM