Home > Article > Backend Development > What is the method to connect sqlserver in php7
This article introduces how to connect php7 to Sqlserver. It mainly includes usage examples of php7.2 connecting to Sqlserver, application skills, summary of basic knowledge points and matters needing attention. It has certain reference value and friends in need can refer to it.
First of all, php needs to enable the sqlsrv extension
1. Download SQLSRV40.EXE (supports php7.0), https:// www.microsoft.com/en-us/download/details.aspx?id=20098
##2. Run SQLSRV40.EXE, Generate extension files, as shown in the figure 3. Copy php_pdo_sqlsrv_7_ts_x64.dll and php_sqlsrv_7_ts_x64.dll to the php/ext directory (my computer is 64-bit)Note: For the difference between ts and nts, see phpinfo 4. Add extension=php_pdo_sqlsrv_7_ts_x64.dll
to php.ini
extension=php_sqlsrv_7_ts_x64.dllOpen extension##5. Install ODBC Driver 11 For SQL (msodbcsql.msi)
https://www.microsoft.com/en-us/download/details.aspx?id=36434
6. Run msodbcsql.msi to complete the installation
Note:
7. Restart apache, the sqlsrv extension is successfully opened
Note: The php7.1 version will not be successfully opened according to this method, the reason The two extension files php_pdo_sqlsrv_7_ts_x64.dll and php_sqlsrv_7_ts_x64.dll are not applicable to php7.1. Please search for these two extension files suitable for php7.1
Recommended learning:
php video tutorialThe above is the detailed content of What is the method to connect sqlserver in php7. For more information, please follow other related articles on the PHP Chinese website!