Microsoft PHP driver for SQL Server 2.0

2.0 Server SQL for driver PHP Microsoft

 

Download:

MSDN download site

 

The major highlight of this release is the addition of the PDO_SQLSRV driver, which adds support for PHP Data Objects (PDO).

 

Comparison SQLSRV driver and PDO_SQLSRV driver:

SQLSRV driver:

<?php

  $serverName = "(local)\sqlexpress"; 
  $connectionOptions = array( "Database"=>"AdventureWorks" );

  /* Connect to SQL Server using Windows Authentication. */ 
  $conn = sqlsrv_connect( $serverName, $connectionOptions );

  /* Get products by querying against the product name.*/ 
  $tsql = "SELECT ProductID, Name, Color, Size, ListPrice FROM Production.Product";

  /* Execute the query. */ 
  $getProducts = sqlsrv_query( $conn, $tsql );

  /* Loop thru recordset and display each record. */ 
  while( $row = sqlsrv_fetch_array( $getProducts, SQLSRV_FETCH_ASSOC ) ) 
  { 
    print_r( $row ); 
  }

  /* Free the statement and connection resource. */
  sqlsrv_free_stmt( $getProducts );
  sqlsrv_close( $conn );

?>

PDO_SQLSRV driver:

<?php

  $serverName = "(local)\sqlexpress"; 

  /* Connect to SQL Server using Windows Authentication. */ 
  $conn = new PDO( “sqlsrv:server=$serverName;Database=AdventureWorks" );

  /* Get products by querying against the product name.*/ 
  $tsql = "SELECT ProductID, Name, Color, Size, ListPrice FROM Production.Product";

  /* Execute the query. */ 
  $getProducts = $conn->query( $tsql );

  /* Loop thru recordset and display each record. */ 
  while( $row = $getProducts->fetch( PDO::FETCH_ASSOC ) ) 
  { 
    print_r( $row ); 
  }

  /* Free the statement and connection resource. */
  $getProducts = NULL;
  $conn = NULL;

?>

Installation see Here

More Infos: Here

 



Comments are closed