PHP + MySql + 存储过程,如何访问“out"?价值? [英] PHP + MySql + Stored Procedures, how do I get access an "out" value?
本文介绍了PHP + MySql + 存储过程,如何访问“out"?价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
严重缺乏与 mysql 和 PHP 中的存储过程有关的文档.我目前有一个通过 PHP 调用的存储过程,如何获取输出参数的值?
Documentation is severely lacking on anything to do with stored procedures in mysql with PHP. I currently have a stored procedure that I call via PHP, how can I get the value of an out parameter?
推荐答案
看来这篇文章已经回答了:
it looks like it's answered in this post:
http://forums.mysql.com/read.php?52,198596,198717#msg-198717
使用 mysqli PHP API:
With mysqli PHP API:
假设 sproc myproc(IN i int, OUT j int):
Assume sproc myproc( IN i int, OUT j int ):
$mysqli = new mysqli( "HOST", "USR", "PWD", "DBNAME" );
$ivalue=1;
$res = $mysqli->multi_query( "CALL myproc($ivalue,@x);SELECT @x" );
if( $res ) {
$results = 0;
do {
if ($result = $mysqli->store_result()) {
printf( "<b>Result #%u</b>:<br/>", ++$results );
while( $row = $result->fetch_row() ) {
foreach( $row as $cell ) echo $cell, " ";
}
$result->close();
if( $mysqli->more_results() ) echo "<br/>";
}
} while( $mysqli->next_result() );
}
$mysqli->close();
这篇关于PHP + MySql + 存储过程,如何访问“out"?价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文