提问人:mmattax 提问时间:9/7/2008 更新时间:1/28/2009 访问量:33622
PHP + MySql + 存储过程,如何访问“out”值?[复制]
PHP + MySql + Stored Procedures, how do I get access an "out" value? [duplicate]
问:
严重缺乏与带有PHP的mysql中的存储过程有关的文档。我目前有一个通过PHP调用的存储过程,如何获取out参数的值?
答:
15赞
John Boker
9/7/2008
#1
看起来在这篇文章中得到了回答:
http://forums.mysql.com/read.php?52,198596,198717#msg-198717
使用 mysqli PHP API:
假设 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();
评论