PHP下如何创建MYSQL存储过程
2个回答
展开全部
直接上代码:
mysql_connect("localhost","user","pwd");
mysql_select_db('testdata') or die (mysql_error());
$sql = "create procedure tb_neaten (in rec int,in pa varchar(15),in qy decimal(10,2),in ar varchar(6))
begin
update test1 set qty=qty-qy where recordnum=rec;
insert into test2 set bname=pa,area=ar,qty=qy,date=date_format(now(),'%Y%m%d'),time=date_format(now(),'%Y%m%d');
end;";
mysql_query($sql) or die (mysql_error());
若是存储过程里含有捕获select结果的语句时,需在mysql_connect时调整参数
mysql_connect("localhost","user","password",1,131072)
执行时,直接运行
mysql_query(tb_neaten(va1,va2,va3,va4));
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询