File tree Expand file tree Collapse file tree
samples/tutorials/php/2.0 PHP Server programming - Stored procedures, Transactions, and UDFs Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77];
88// Establishes the connection
99$ conn = sqlsrv_connect ($ serverName , $ connectionOptions );
10- ////////////////// STORED PROCEDURE /////////////////////////
10+
11+ /*
12+ * Stored Procedure
13+ */
14+
1115$ tsql = "CREATE PROCEDURE sp_GetCompanies22 AS BEGIN SELECT [CompanyName] FROM SalesLT.Customer END " ;
1216$ storedProc = sqlsrv_query ($ conn , $ tsql );
1317if ($ storedProc == false ) {
5054sqlsrv_free_stmt ($ storedProc );
5155?>
5256<?php
53- ////////////////// TRANSACTION /////////////////////////
57+ /*
58+ * Transaction
59+ */
60+
5461if (sqlsrv_begin_transaction ($ conn ) == false ) {
5562 echo "Error opening connection " ;
5663 die (FormatErrors (sqlsrv_errors ()));
8592
8693?>
8794<?php
88- ////////////////// UDF /////////////////////////
95+ /*
96+ * UDF
97+ */
8998// Dropping function if it already exists
9099$ tsql1 = "IF OBJECT_ID(N'dbo.ifGetTotalItems', N'IF') IS NOT NULL DROP FUNCTION dbo.ifGetTotalItems; " ;
91100$ getProducts = sqlsrv_query ($ conn , $ tsql1 );
You can’t perform that action at this time.
0 commit comments