传入和传出参数的MYSQL存储过程

下文为您介绍的是PHP调用MYSQL存储过程中调用传入参数的存储过程及传出参数的存储过程这两种情况,该调用方法供您参考,希望对您有所帮助。

传入参数的MYSQL存储过程
$sql = "
create procedure myproce2(in score int)
begin
if score >= 60 then
select 'pass';
else
select 'no';
end if;
end;
";
mysql_query($sql);//创建一个myproce2的存储过程
$sql = "call test.myproce2(70);";
mysql_query($sql);//调用myproce2的存储过程,看不到效果,可以在cmd下看到结果。

传出参数的MYSQL存储过程
$sql = "
create procedure myproce3(out score int)
begin
set score=100;
end;
";
mysql_query($sql);//创建一个myproce3的存储过程
$sql = "call test.myproce3(@score);";
mysql_query($sql);//调用myproce3的存储过程
$result = mysql_query('select @score;');
$array = mysql_fetch_array($result);
echo '<pre>';print_r($array);
原文地址:https://www.cnblogs.com/rooney/p/2387741.html