Firstly, I apologize because I have minimal experience with Linux so I may just not be understanding something obvious. Ultimately, I am trying to query a MSSQL database via PHP.
I have installed freetds and unixODBC. I confirmed the setup with both tsql (freetds) and isql (unixODBC) and everything works. The problem is when I try to connect from PHP using pdo using the following: $db = new PDO('odbc:mssql', '$username','$password');
I receive a fatal PHP error: Uncaught PDOException: could not find driver...
Upon further inspection, I looked at my PHP info file and the available PDO drivers are: mysql and sqlite. How/where do I get the pdo odbc driver for PHP7? In the PHP documentation, it appears that the driver is included in the PHP source, but the only option I see is to use ./configure and from what I understand, that is only to compile from source.
Is there a way to add the driver to an already compiled version of PHP7? I feel like I am missing something stupid. Any help would be greatly appreciated!
If your OS is UBUNTU
Install the unixODBC driver manager and Microsoft ODBC driver for Linux
Run installer
Install PHP dependenceis
Install sqlsrv (check last version with pecl search sqlsrv)
Install pdo_sqlsrv (check last version with pecl search sqlsrv)
Load extensions
Restart PHP-FPM
For windows https://learn.microsoft.com/en-us/sql/connect/php/loading-the-php-sql-driver?view=sql-server-2017
CentOS 7
or via yum look; https://webtatic.com/packages/php70/