How does PHP obtain the output parameters of the mssql stored procedure? _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
How does PHP obtain the output parameters of the mssql stored procedure ?. Use the built-in function 1 in phpmssql. initialize the stored procedure $ stmtmssql_init (procedurename); 2. bind variable input parameters: mssql_bind ($ stmt, @ operate_flag, $ status, SQLVARCH use built-in functions in php mssql
1. initialize the stored procedure
$ Stmt = mssql_init ('procedure name ');
2. bind variables
Input parameters:
Mssql_bind ($ stmt, '@ operate_flag', $ status, SQLVARCHAR); note that the third parameter must be a variable; otherwise, an error is returned.
Output parameters:
Mssql_bind ($ stmt, '@ return_mess', $ output, SQLVARCHAR, true); the fifth parameter indicates whether the output tag is used.
Execute the stored procedure
$ Retult = mssql_execute ($ stmt); the second parameter is whether to return the result set. The change setting is irrelevant to the return value.
Disconnect
Mssql_free_statement ($ stmt );
Output value in variable $ output

When a stored procedure has multiple returned result sets and return values, the processing method is different:
Explanation from PHP maintainers:
Originally, this call method was certainly supported by PHP 4.3.
"However, since PHP version 4.3," they said, "to be compatible with stored procedures and return multiple result sets, PHP has changed this feature ."
"If you do not need a result set, you should set the Second Optional parameter of mssql_execute to TRUE, so that you can get the output parameter after the mssql_execute method ."
"If you want to return the result set, you should call mssql_next_result once for each result set. After the last result set is returned, you can call mssql_next_result to obtain the returned value FALSE. in this case, you can access the output parameters.
Modify the code as follows:
Mssql_next_result ($ result );

Built-in functions in mssql 1. initialize the stored procedure $ stmt = mssql_init (procedure name); 2. bind variable input parameters: mssql_bind ($ stmt, @ operate_flag, $ status, SQLVARCH...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.