我如何从存储过程获取输出值到php变量..
示例存储过程:
DROP PROCEDURE `test`; CREATE DEFINER=`mydbinstance`@`%` PROCEDURE `test`(OUT `max` INT(11)) NOT DETERMINISTIC MODIFIES SQL DATA SQL SECURITY DEFINER
BEGIN
SELECT MAX(slno)+1 INTO @max FROM table1;
SELECT @max;
END
php:
$stmt=mysqli_query($conn,"CALL test();");
答案 0 :(得分:0)
您应该能够以与任何其他查询相同的方式获取存储过程的结果:
$stmt = mysqli_query($conn,"CALL test();");
if ($row = mysqli_fetch_row($stmt)) {
$value = $row[0];
}