Microsoft Drivers 3.0 for PHP for SQL Server Released!

Dear SQL Server Developer Community, thank you very much for your feedback in driving our roadmap. Adding another milestone, the PHP Driver team is very excited to announce the availability of the Microsoft Drivers 3.0 for PHP for SQL Server Community Technology Preview 1!

The major highlights of this release include: support for SQL Server Codename “Denali” features, and Buffered Queries. The “Denali” features include support for AlwaysOn Connectivity, encompassing support for Multi-Subnet Failover, connectivity to AlwaysOn Availability Groups and Read-Only Routing, and support for SQL Express LocalDB.

SQL Server Codename “Denali”: LocalDB

The Microsoft Drivers for PHP for SQL Server include support for SQL Express LocalDB, a new distribution of SQL Server. LocalDB is a lightweight install, providing only the database engine. This engine is brought up automatically when an application connects to the instance, and provides easy connection-time parameters for attaching file-based databases. This feature significantly simplifies the development experience, as well as reducing the installation components necessary to develop for SQL Server. Enabling support for LocalDB is as easy as changing the connection string. An example in the SQLSRV driver:

$serverName = "(localdb)\v11.0";
$connectionOptions = array( "Database"=>"AdventureWorks", “AttachDBFileName”=>”AdventureWorks.mdf” );
/* Connect to SQL Express LocalDB. */
$conn = sqlsrv_connect( $serverName, $connectionOptions );

And an example in the PDO_SQLSRV driver:

<?php $conn = new PDO("sqlsrv:Server=(localdb)\v11.0 ; Database = AdventureWorks ; AttachDBFilename = AdventureWorks.mdf", "", ""); ?>

All functionality expected from a standard SQL Server Express instance will also function with LocalDB, as well as all standard driver functions. Additionally, databases attached at connection time will automatically be attached in the engine if they are not already, or redirected to the existing attached file if the engine already has it attached.

SQL Server Codename “Denali”: AlwaysOn Connectivity

The Microsoft Drivers for PHP for SQL Server include support for the AlwaysOn Connectivity feature of SQL Server Codename “Denali”:
SQL Server AlwaysOn is the new high availability and disaster recovery solution for the next release of SQL Server. Using AlwaysOn businesses can achieve increased application availability for their mission critical applications and get higher returns on their high availability investments through better utilization of hardware resources. AlwaysOn also increases productivity and lowers TCO by greatly simplifying high availability deployment and management.

The driver now supports the two new connection options “ApplicationIntent” and “MultiSubnetFailover” to support AlwaysOn connectivity.

Buffered Queries

Finally, the driver now provides support for resultsets to be buffered on the client-side by the driver. This feature is very common amongst PHP database drivers and we are proud to bring support for this in our 3.0 CTP1 release. This is an opt-in feature which caches the entire resultset from a query into memory, therefore reducing subsequent round-trips to the server usually required to fetch the resultset row-by-row. An example where Buffered Queries is enabled in the SQLSRV driver is presented below:

<?php /* Get products by querying against the product name.*/ $tsql = "SELECT ProductID, Name, Color, Size, ListPrice FROM Production.Product"; /* Execute the query, buffered queries enabled */ $getProducts = sqlsrv_query( $conn, $tsql, null, array("Scrollable"=>"buffered")););?>

And also in the PDO_SQLSRV driver:

<?php /* Get products by querying against the product name.*/ $tsql = "SELECT ProductID, Name, Color, Size, ListPrice FROM Production.Product"; /* Prepare and execute the query, buffered queries enabled */ $stmt = $conn->prepare( $tsql, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED)); $stmt->execute();?>

Documentation, Feedback and Download

You can find documentation on the driver at our MSDN documentation page, provide feedback on our MSDN Forum and at the SQL Server Connect Site, and (most importantly!) download the driver here. Also note that you will require the SQL Server Codename “Denali” Native Access Client, available here. We encourage you to download and play with this CTP and provide us feedback. Please note that we still continue to support our v2.0 release.

I’d like to thank everyone on behalf of the team for supporting us in our endeavors to provide you with a high-quality driver. Happy downloading!




Jonathan Guerin
Program Manager
Microsoft Drivers for PHP for SQL Server
SQL Connectivity
Microsoft Corporation