
存取 PHP MySql 儲存過程中的輸出值
MySQL 文件提供了有關存取儲存過程中的輸出參數的有限指導。以下是如何使用PHP 檢索輸出參數值:
答案:
如MySQL 論壇之前的討論中提到的:
對於PHP mysqli API,使用帶有IN 參數(i) 和OUT 參數(j) 的預存程序,例如“myproc( IN i int, OUT j int)”:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <code class = "php" > $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()) {
echo "<b>Result #$results</b>:<br/>" ;
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();</code>
|
登入後複製
以上是如何在 PHP 中從 MySQL 預存程序存取 OUT 參數?的詳細內容。更多資訊請關注PHP中文網其他相關文章!