How to Connect to a Microsoft SQL Database using PDO?


#1

I’m trying to access a Microsoft SQL database using PDO, but I’m getting the error message “Fatal error: Uncaught exception ‘PDOException’ with message ‘could not find driver’”.
From what I’ve found, I need to add the php_pdo_sqlsrv_56_nts.dll to my php5 directory and then add it to my php.ini file. however I have not been able to find a way to move the dll into the directory where the rest of the php .dll’s are stored. Is there an easy way for me to move this dll into place and get this working?
Or is there a different way that I should be doing this?

Thanks in advance for any help!


#2

have you used this command to see if sqlsrv is installed

<?php print_r(PDO::getAvailableDrivers()); ?>

#3

Current drivers installed are: dblib, mysql, pgsql, and sqlite

But not sqlsrv.


#4

you’re databse SQL SRVR is stored with c9.io or an external service?
Link of the driver for Ubuntu : https://www.microsoft.com/en-us/download/details.aspx?id=50419


#5

After, you can look this : http://onefinepub.com/2013/03/ms-sql-odbc-ubuntu/
Maybe can help you. Have a Good Luck !


#6

Hi thank you so much for your post! Now it may be that I just have no experience with linux and therefore this is a simple problem, but I don’t know what directory php is install on in c9 and I can’t figure out how to change directory (or which directory it is in) to uninstall libodbc1 as required in your last post in installing the driver.

How do I cd to the directory that has php installed?