Independent of doing a 'clean' installation or just updating some component (OS, PHP, Vcxx and MSSQL) it is highly recommended to check the SQL server driver compatibility with the other components not to install anything wrong. The procedure described below also serves for the installation of the extension sqlsrv.
There is a table which shows which version of the SQL Server driver is compatible with the respective version of PHP.
1 - Download the microsoft website driver at that link
2 - Unzip the file see corresponding version of the driver with the php version and whether it is thread safe or not(see Thread Safety
in the phpinfo()
).
3 - Copy the dll to the ext php installation folder.
4 - Finally add the upload of the extension to php.ini and restart the server.
extension=php_pdo_sqlsrv_VERSAO_THREAD_SAFE_OU_NAO.dll
For non thread safe
extension=php_pdo_sqlsrv_55_nts.dll
For thread safe
extension=php_pdo_sqlsrv_55_ts.dll
To check if extension has been loaded correctly create a new file with the code:
<?php
phpinfo();
If you have no problem phpinfo will be loaded as the image below:
Another way to check if the PDO driver has been installed correctly is to use getAvailableDrivers()
<?php
echo "<pre>";
print_r(PDO::getAvailableDrivers());
The result is something like:
Array
(
[0] => mysql
[1] => sqlsrv
[2] => pgsql
[3] => sqlite
)
Which version of php you’re using?
– rray
the version is 5.5.8
– wwwjsw