pdo and ODBC to connect to SQL Server_PHP tutorial
pdo and ODBC to connect to SQL Server
Download the driver. I downloaded the 2.0 version. After downloading, install the release 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 (manual, if your English is good enough, you can read it, hehe)
SQLServerDriverForPHP_License.rtf
SQLServerDriverForPHP_Readme.htm (readme file)
The following is the content in the readme file, let me translate it:
Driver file
PHP version
Thread safety
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
Regarding the difference between VC6 and VC9, there are also non-thread safety and thread safety
The VC6 version is compiled using the Visual Studio 6 compiler. If you are using Apache+PHP under Windows, please select the VC6 version.
The VC9 version is compiled using the Visual Studio 2008 compiler. If you are using IIS+PHP under Windows, please select the VC9 version.
Non Thread Safe means non-thread safety, no thread (Thread) safety check is performed during execution;
Thread Safe is thread safe. Thread safety checks will be performed during execution to prevent CGI execution from starting new threads when new requirements arise and exhausting system resources;
Start configuration
I use the PHP environment built by APMserv (Apache 2.2.9+PHP 5.2.6+MySQL 5.1.28). I want to use thread safety, so I choose php_sqlsrv_52_ts.dll and php_pdo_sqlsrv_52_ts.dll.
To start working, first copy the file to the ext directory under the PHP folder, and then configure the file php.ini
Add after Extensions:
;extension=php_sqlsrv_52_ts.dll
;extension=php_pdo_sqlsrv_52_ts.dll
Restart Apache again.
Finally, to test whether it is successful, take a look at phpinfo’s sqlsrv
As shown in the picture, this means the connection is successful! ! Let’s get to work!
Tutorial on connecting to database
Anyone who has used SQL Server should know that there are two commonly used authentication methods in SQL Server, one is local system account authentication (Windows Authentication), the other is using user name and password (SQL Server Authentication), and the second is This authentication method must enable the mixed mode of SQL Server.
1.Windows Authentication connection part code snippet
*/
$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));
}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

When you log in to someone else's steam account on your computer, and that other person's account happens to have wallpaper software, steam will automatically download the wallpapers subscribed to the other person's account after switching back to your own account. Users can solve this problem by turning off steam cloud synchronization. What to do if wallpaperengine downloads other people's wallpapers after logging into another account 1. Log in to your own steam account, find cloud synchronization in settings, and turn off steam cloud synchronization. 2. Log in to someone else's Steam account you logged in before, open the Wallpaper Creative Workshop, find the subscription content, and then cancel all subscriptions. (In case you cannot find the wallpaper in the future, you can collect it first and then cancel the subscription) 3. Switch back to your own steam

Recently, many users have been asking the editor, how to download links starting with 115://? If you want to download links starting with 115://, you need to use the 115 browser. After you download the 115 browser, let's take a look at the download tutorial compiled by the editor below. Introduction to how to download links starting with 115:// 1. Log in to 115.com, download and install the 115 browser. 2. Enter: chrome://extensions/ in the 115 browser address bar, enter the extension center, search for Tampermonkey, and install the corresponding plug-in. 3. Enter in the address bar of 115 browser: Grease Monkey Script: https://greasyfork.org/en/

HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

The superpeople game can be downloaded through the steam client. The size of this game is about 28G. It usually takes one and a half hours to download and install. Here is a specific download and installation tutorial for you! New method to apply for global closed testing 1) Search for "SUPERPEOPLE" in the Steam store (steam client download) 2) Click "Request access to SUPERPEOPLE closed testing" at the bottom of the "SUPERPEOPLE" store page 3) After clicking the request access button, The "SUPERPEOPLECBT" game can be confirmed in the Steam library 4) Click the install button in "SUPERPEOPLECBT" and download

Many users need to download files when using Quark Network Disk, but we want to save them locally, so how to set this up? Let this site introduce to users in detail how to save files downloaded from Quark Network Disk back to the local computer. How to save files downloaded from Quark network disk back to your local computer 1. Open Quark, log in to your account, and click the list icon. 2. After clicking the icon, select the network disk. 3. After entering Quark Network Disk, click My Files. 4. After entering My Files, select the file you want to download and click the three-dot icon. 5. Check the file you want to download and click Download.

foobar2000 is a software that can listen to music resources at any time. It brings you all kinds of music with lossless sound quality. The enhanced version of the music player allows you to get a more comprehensive and comfortable music experience. Its design concept is to play the advanced audio on the computer The device is transplanted to mobile phones to provide a more convenient and efficient music playback experience. The interface design is simple, clear and easy to use. It adopts a minimalist design style without too many decorations and cumbersome operations to get started quickly. It also supports a variety of skins and Theme, personalize settings according to your own preferences, and create an exclusive music player that supports the playback of multiple audio formats. It also supports the audio gain function to adjust the volume according to your own hearing conditions to avoid hearing damage caused by excessive volume. Next, let me help you

As an indispensable accompaniment to children's growth, Beilehu's children's songs have won the love of countless parents and children with their cheerful melody, vivid pictures and entertaining and educational content. In order to allow babies to enjoy the joy brought by children's songs anytime and anywhere, many parents hope to download Beilehu's children's songs to their mobile phones or tablets so that they can listen to their children at any time, but how to save Beilehu's children's songs? On your mobile phone, this tutorial will bring you a detailed introduction. Users who don’t understand it yet can come and read along with this article to learn more. Beilehu Nursery Rhymes Download Children's Songs Multi-Picture Tutorial: Open the software and select a children's song you want to download. The editor takes "Classic Children's Songs" as an example. 2. Click the "Download" button below the children's song star.

As a convenient and practical network disk tool, Quark can help users easily obtain their favorite resources. What if you want to download a file locally? Let the editor tell you now, let’s learn it together! How to download Quark Network Disk to local sharing method 1. First open the Quark software, enter the homepage, and click the [Cloud Icon] on the lower right; 2. Then on the Quark Network Disk page, we click the [Document] function; 3. Then go to the document page, select the file you want to download, and click the [three-dot icon]; 4. After the final click, we click [Download] in the pop-up dialog box;
