--TEST-- execute with string type in bind parameters. --SKIPIF-- --FILE-- "$databaseName", "UID"=>"$uid", "PWD"=>"$pwd"); $conn = sqlsrv_connect( $server, $connectionInfo); if( $conn === false) { echo "Could not connect.
"; die( print_r( sqlsrv_errors(), true)); } /* Prepare with string type in parameter. */ $tsql = "SELECT * FROM Sales.SalesOrderDetail WHERE CarrierTrackingNumber=(?)"; //Pass in parameters directly $params = array( '8650-4A20-B1'); $stmt = sqlsrv_prepare( $conn, $tsql, $params); //Pass in parameters through reference //$ctn="8650-4A20-B1"; //$stmt = sqlsrv_prepare( $conn, $tsql, array(&$ctn)); echo "String Type, Select Query:
"; if( $stmt ) { echo "Statement prepared.
"; } else { echo "Error in preparing statement.
"; die( print_r( sqlsrv_errors(), true)); } /* Execute the statement. Display any errors that occur. */ if( sqlsrv_execute( $stmt)) { echo "Statement executed.
"; } else { echo "Error in executing statement.
"; die( print_r( sqlsrv_errors(), true)); } $soID = 0; $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC); while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC)) { echo $row['SalesOrderID'].", ".$row['CarrierTrackingNumber']."
"; $soID = $row['SalesOrderID']; } echo "
"; sqlsrv_free_stmt( $stmt); disableTrigger($conn); /* Prepare with string type in parameter. */ $tsql = "UPDATE Sales.SalesOrderDetail SET OrderQty=(?) WHERE CarrierTrackingNumber=(?)"; //Pass in parameters directly $params = array(5, '8650-4A20-B1'); $stmt = sqlsrv_prepare( $conn, $tsql, $params); //Pass in parameters through reference //$oq=5; //$ctn="8650-4A20-B1"; //$stmt = sqlsrv_prepare( $conn, $tsql, array(&$oq, &$ctn)); echo "String Type, Update Query:
"; if( $stmt ) { echo "Statement prepared.
"; } else { echo "Error in preparing statement.
"; die( print_r( sqlsrv_errors(), true)); } /* Execute the statement. Display any errors that occur. */ if( sqlsrv_execute( $stmt)) { echo "Statement executed.
"; } else { echo "Error in executing statement.
"; die( print_r( sqlsrv_errors(), true)); } echo sqlsrv_rows_affected( $stmt)." rows affected.

"; sqlsrv_free_stmt( $stmt); /* Revert back the Update. */ $tsql = "UPDATE Sales.SalesOrderDetail SET OrderQty=(?) WHERE CarrierTrackingNumber=(?)"; //Pass in parameters directly $params = array(1, '8650-4A20-B1'); $stmt = sqlsrv_prepare( $conn, $tsql, $params); //Pass in parameters through reference //$oq=1; //$ctn="8650-4A20-B1"; //$stmt = sqlsrv_prepare( $conn, $tsql, array(&$oq, &$ctn)); echo "String Type, Update Query:
"; if( $stmt ) { echo "Statement prepared.
"; } else { echo "Error in preparing statement.
"; die( print_r( sqlsrv_errors(), true)); } /* Execute the statement. Display any errors that occur. */ if( sqlsrv_execute( $stmt)) { echo "Statement executed.
"; } else { echo "Error in executing statement.
"; die( print_r( sqlsrv_errors(), true)); } echo sqlsrv_rows_affected( $stmt)." rows affected.
"; /* Free the statement and connection resources. */ sqlsrv_free_stmt( $stmt); sqlsrv_close( $conn); ?> --EXPECT-- String Type, Select Query:
Statement prepared.
Statement executed.
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1
51108, 8650-4A20-B1

String Type, Update Query:
Statement prepared.
Statement executed.
52 rows affected.

String Type, Update Query:
Statement prepared.
Statement executed.
52 rows affected.