您的位置:首页 > 编程语言 > PHP开发

php调用mysql存储过程输出参数

2011-02-18 15:04 676 查看
<!--

create procedure in_out (in parameter integer)

begin

declare variable varchar(20);

if parameter=1 then

set variable='MySQL';

else

set variable='PHP';

end if;

insert into userinfo(username) values (variable);

end;

-->

<!--

create procedure outstatement(out str varchar(50))

begin

set str="hello the world!";

end ;

-->

<?php

define('CLIENT_MULTI_RESULTS',131072);

$host="localhost";

$user="root";

$password="";

$id=$_REQUEST["id"];

$cxn = mysql_connect($host,$user,$password,1,CLIENT_MULTI_RESULTS) or die("Could not connect: ".mysql_error());

$db=mysql_select_db("test");

$res=mysql_query("call outstatement(@str)",$cxn);

$res=mysql_query("select @str",$cxn);

$row=mysql_fetch_row($res);

echo $row[0];

?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: