How to get the output parameters of mssql stored procedure in PHP? _PHP Tutorial

WBOY
Release: 2016-07-14 10:06:56
Original
892 people have browsed it

Use the 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 will be reported
Output parameters:
mssql_bind ( $stmt, '@return_mess', $output, SQLVARCHAR, true ); The fifth parameter is whether it is an output tag
Execute stored procedure
$retult = mssql_execute ( $stmt ); The second parameter is whether to return the result set. Changing the setting has nothing to do with the return value
Disconnect
mssql_free_statement ( $stmt );
The output value is in the variable $output

When the stored procedure has multiple return result sets and return values, the processing method is different:
Explanation from the PHP maintainer:
Originally, our calling method was definitely supported before PHP 4.3.
"However, since PHP version 4.3," they said, "in order to be compatible with stored procedures returning multiple result sets, PHP has changed this feature."
"If you don't need the result set, you should set the second optional parameter of mssql_execute to TRUE so that you can get the output parameters after the mssql_execute method."
"If you need to return result sets, you should call mssql_next_result once for each result set. After the last result set is returned, you will get the return value FALSE by calling mssql_next_result. At this time, you can access the output parameters .
Modify the code as follows
mssql_next_result($result);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477903.htmlTechArticleUse the built-in function in php mssql 1. Initialize the stored procedure $stmt = mssql_init (procedure name); 2. Bind variable input parameters: mssql_bind ( $stmt, @operate_flag, $status, SQLVARCH...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!