PHP connection to SqlServer (most comprehensive in history)

Source: Internet
Author: User
Tags microsoft odbc driver 11 for sql server
PHP connection to SqlServer experience (most comprehensive in history) classification: PHP Time: May 20, 2016

First of all, I would like to explain why I wrote the article "PHP connection to SqlServer (the most comprehensive in history? I. This problem is rarely used by PHP programmers. it is basically PHP + MySQL. ii. There are many duplicate content on the internet that cannot completely solve the problem. In general, the problems that PHP may encounter when connecting to SqlServer and the solutions of PHP programmer Lei Xuesong are summarized and shared with you. you can use PHP to connect to SqlServer directly.

PHP programmer Lei Xuesong uses PHP to connect to the SqlServer environment: Windows 64-bit system, PHP integrated environment wamp (the software version includes apache2.4.9, mysql5.6.17, php5.5.12 ). By the way, there are two articles on PHP and SqlServer in the personal blog of PHP programmer Lei Xuesong, if you are interested, you can take a look at the installation of PHP extension MSSql and Thinkphp operation MsSQL in Linux.

Mssql functions can be used before PHP5.3. mssql on the PHP official website prompts that the extension is unavailable in PHP 5.3 or later versions of Windows. after PHP7.0.0, mssql is deleted, use PDO_SQLSRV (Windows only), PDO_ODBC, SQLSRV (Windows only), and Unified odbc api extension. Therefore, in windows, PHP only supports PDO_SQLSRV (Windows only) and SQLSRV (Windows only) connection to SqlServer.

1. when introducing PHP extensions, be sure to pay attention to the PHP version, ts, or ETS. please refer to the PHP programmer Lei Xuesong's blog "PHP version differences and usage details".

2. if the Microsoft PHP Driver version is 3.1 or 3.2, you must first download and install Microsoft ODBC Driver 11 for SQL Server on the Microsoft official website.

3. the PHP extensions sqlsrv and pdo_sqlsrv provided by Microsoft only support 32-bit, that is, x86 platform, but not 64-bit, if you need to install 64 PHP extensions, you must use the unofficial sqlsvr and pdo_sqlsrv Extensions. for 32-bit extensions, you can download them directly from the Microsoft official website. PHP extension sqlsrv and pdo_sqlsrv download unofficial 32-bit and 64-bit addresses, 32-bit support 5.3, 5.4, 5.5, 64-bit support 5.6, 5.5.

4. after the sqlsvr extension is installed, open phpinfo () to check whether sqlsvr and pdo_sqlsrv exist. Note that the main configuration file must be used when running the command line. Command: php.exe-c php. ini-f file. php.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.