How to Use PHP with SQL Server
Intended audience: Web developers who are not familiar with SQL Server, yet want to learn how to use a SQL Server database with their PHP web site.
The links below are external links and provide information and guidance on creating dynamic web pages using PHP, SQL Server and IIS as part of web site development. This information assumes that you are already familiar with PHP development. If you are not familiar with PHP and are looking for information or additional programming resources for this language, visit http://www.php.net/.
This topic is a how to. Please keep it as clear and simple as possible. Avoid speculative discussions as well as a deep dive into underlying mechanisms or related technologies. |
Note: The following links are all external.
Setting up your environment
- Getting Started with PHP on Windows (initial setup, including manual setup)
- Getting Started with PHP on Windows with SQL Server Express (initial setup and basic usage)
- Getting Started with the SQL Server Driver for PHP
- SQL Server Driver for PHP: Understanding Windows Authentication
Connecting to SQL Server from PHP
- Connecting to the SQL Server
- How to: Connect Using Windows Authentication
- How to: Connect Using SQL Server Authentication
Storing and Retrieving Data
- Execute a query using sqlsrv_query
- Execute a prepared statement using sqlsrv_execute
- How to: Perform Parameterized Queries
- How to: Perform Transactions
- Retrieving data
- Retrieve data as an array
- Retrieve data as a PHP object
- Retrieve a row of data
- Retrieve a field from the current row
- Storing images/using FILESTREAM
PHP Data Object (PDO) Support
- Retrieving a row of data
- Retrieve all rows as an array
- Retrieve one column from a row
- Retrieve a row as a PHP object
Improving Performance
Security Concerns
- What's the Right Way to Prevent SQL Injection in PHP Scripts?
- How and Why to Use Parameterized Queries
See Also
- Wiki: Development Portal (en-US)
- SQL Server Overview
- [[Introduction to Development with SQL Server]]
- [[How to use ASP.NET with SQL Server (en-US)]]
Other Languages
This article is also available in the following languages: