File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
samples/tutorials/php/2.0 PHP Server programming - Stored procedures, Transactions, and UDFs Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 7
7
];
8
8
// Establishes the connection
9
9
$ conn = sqlsrv_connect ($ serverName , $ connectionOptions );
10
- ////////////////// STORED PROCEDURE /////////////////////////
10
+
11
+ /*
12
+ * Stored Procedure
13
+ */
14
+
11
15
$ tsql = "CREATE PROCEDURE sp_GetCompanies22 AS BEGIN SELECT [CompanyName] FROM SalesLT.Customer END " ;
12
16
$ storedProc = sqlsrv_query ($ conn , $ tsql );
13
17
if ($ storedProc == false ) {
50
54
sqlsrv_free_stmt ($ storedProc );
51
55
?>
52
56
<?php
53
- ////////////////// TRANSACTION /////////////////////////
57
+ /*
58
+ * Transaction
59
+ */
60
+
54
61
if (sqlsrv_begin_transaction ($ conn ) == false ) {
55
62
echo "Error opening connection " ;
56
63
die (FormatErrors (sqlsrv_errors ()));
85
92
86
93
?>
87
94
<?php
88
- ////////////////// UDF /////////////////////////
95
+ /*
96
+ * UDF
97
+ */
89
98
// Dropping function if it already exists
90
99
$ tsql1 = "IF OBJECT_ID(N'dbo.ifGetTotalItems', N'IF') IS NOT NULL DROP FUNCTION dbo.ifGetTotalItems; " ;
91
100
$ getProducts = sqlsrv_query ($ conn , $ tsql1 );
You can’t perform that action at this time.
0 commit comments