Tutorial on connecting pdo and ODBC to SQLServer_PHP

Source: Internet
Author: User
Tags vc9
Pdo and ODBC are used to connect to SQLServer. Pdo and ODBC are used to connect to SQLServer to download the driver. I downloaded 2.0 and installed the release program. the following files are available: php Tutorial _ pdo_sqlsrv_52_nts.dllphp_pdo_sqlsrv_52 _ pdo and ODBC to connect to SQL Server.

Download the driver. I downloaded 2.0. after the download, install and release the program, which contains the following files:

Php Tutorial _ pdo_sqlsrv_52_nts.dll

Php_pdo_sqlsrv_52_ts.dll

Php_pdo_sqlsrv_53_nts_vc6.dll

Php_pdo_sqlsrv_53_nts_vc9.dll

Php_pdo_sqlsrv_53_ts_vc6.dll

Php_pdo_sqlsrv_53_ts_vc9.dll

Php_sqlsrv_52_nts.dll

Php_sqlsrv_52_ts.dll

Php_sqlsrv_53_nts_vc6.dll

Php_sqlsrv_53_nts_vc9.dll

Php_sqlsrv_53_ts_vc6.dll

Php_sqlsrv_53_ts_vc9.dll

SQLServerDriverForPHP. chm)

SQLServerDriverForPHP_License.rtf

SQLServerDriverForPHP_Readme.htm (self-report file)

The content in the self-report file is as follows:

Driver file
PHP version
Thread security
For PHP. dll

Php_sqlsrv_53_nts_vc6.dll

Php_pdo_sqlsrv_53_nts_vc6.dll
5.3
No
Php5.dll

Php_sqlsrv_53_nts_vc9.dll

Php_pdo_sqlsrv_53_nts_vc9.dll
5.3
No
Php5.dll

Php_sqlsrv_53_ts_vc6.dll

Php_pdo_sqlsrv_53_ts_vc6.dll
5.3
Yes
Php5ts. dll

Php_sqlsrv_53_ts_vc9.dll

Php_pdo_sqlsrv_53_ts_vc9.dll
5.3
Yes
Php5ts. dll

Php_sqlsrv_52_nts.dll

Php_pdo_sqlsrv_52_nts.dll
5.2
No
Php5.dll

Php_sqlsrv_52_ts.dll

Php_pdo_sqlsrv_52_ts.dll
5.2
Yes
Php5ts. dll

The differences between VC6 and VC9 include non-thread security and thread security.

VC6 is compiled using the Visual Studio 6 compiler. if you are using Apache + PHP in windows, select VC6.

VC9 is compiled using the Visual Studio 2008 compiler. if you are using IIS + PHP in windows, select VC9.

Non-Thread Safe is Non-Thread security and does not perform Thread security checks during execution;

Thread Safe is Thread security. during execution, the Thread security check is performed to prevent the new Thread from consuming system resources by starting the CGI execution mode;


Start configuration


I am using the PHP environment set up by APMserv (Apache 2.2.9 + PHP 5.2.6 + MySQL 5.1.28). If I want to use thread security, select php_sqlsrv_52_ts.dll and php_pdo_sqlsrv_52_ts.dll.

First, copy the file to the ext directory under the PHP folder, and then in the configuration file php. ini
Added the following to Extensions:

; Extension = php_sqlsrv_52_ts.dll

; Extension = php_pdo_sqlsrv_52_ts.dll

Restart Apache.

Finally, test whether it is successful. check the sqlsrv of phpinfo.


The connection is successful !! Start working!

Database Connection tutorial

Users who have used SQL Server should be clear that SQL Server commonly uses two Authentication methods, one is local system account Authentication (Windows Authentication ), one is to use the user name and password (SQL Server Authentication), and the second Authentication method must enable the hybrid mode of SQL Server.

1. part of Windows Authentication connection code segment


*/

$ ServerName = "(local )";
$ ConnectionInfo = array ("Database" => "test", "ConnectionPooling" => false );
$ Conn = sqlsrv_connect ($ serverName, $ connectionInfo );
If ($ conn = false)
{
Echo "connection failed! ";
Die (print_r (sqlsrv_errors (), true ));
}

Server downloads the driver. I downloaded 2.0. after the download, install and release the program, which contains the following files: php Tutorial _ pdo_sqlsrv_52_nts.dll php_pdo_sqlsrv_52 _...

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.