Maybe you should try PDO with the Sqlsrv plugin (this is what I’m using to connect to my other boss’s software that uses the SQL Server 2014 database):
$connection = new PDO("sqlsrv:Server=" . $server . ";Database=" . $database, $username, $password);
$connection->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
You can download the plugin here
https://www.microsoft.com/en-ca/download/details.aspx?id=36434
In Xampp, you should copy the dll in the folder:
C:\xampp\php\ext
And you should add this line to your php.ini
extension = php_pdo_sqlsrv_56_ts.dll
Note:
Don’t forget to restart your server so that it can take into account the new php.ini file.
OBS. PHP 7
PHP extension Dlls are compiled to work in a single version of PHP. The PHP 5.6 DLL will lock in PHP 7, and the PHP 7 DLL will lock in PHP 7.1. So, at first, make sure you’re using only the correct version in the ext
and in the php.ini
Also note that PHP is compiled from two ways in Windows: thread safe and non thread safe. This also influences which extension you should use (again, don’t mix garlic with oranges).
Ah, almost forgetting, from PHP 7 we also have a compilation for x64 and another for x86. Again, you need to choose the correct version here too.
Assuming you’re using the version Thread Safe (the one that comes along with XAMPP/Apache generally), download the latest extension to work with SQL Server. The easiest way is look at the driver github repository, in the releases part and download only the version you want.
Today support for PHP 7.1 is still in preview, and the latest version that’s the one.
Download only the zip for PHP 7.1, choose the architecture, thread safe or not, and extract only them in the folder ext
and insert into php.ini
.
// suporte PDO
extension=php_pdo_sqlsrv_71_ts.dll
// sem PDO
extension=php_sqlsrv_71_ts.dll
Finally, if something doesn’t work out, you may need to update the Microsoft ODBC Driver 13 for SQL Server. SQL Server Express 2014 uses version 11 must driver for connection, and so remind me not know if the new version of the driver for PHP needs you to update the ODBC as well.
Did you ever do that PDO Drivers for SQL Server procedure?
– rray