<?php $conn = mysql_connect('localhost','root','') or die ("数据连接错误!!!"); mysql_select_db('gmmenager',$conn); $sql = "create procedure myproce() begin insert into user (name,password) values ('333','ad333fdf'); end;"; mysql_query($sql); $sql = "call gmmenager.myproce();"; $res = mysql_query($sql); if($res){ mysql_query("DROP PROCEDURE myproce;"); echo "ok"; }else{ mysql_query("DROP PROCEDURE myproce;"); echo "no"; } ?>
在MySQL中查看存储过程:show create procedure myproce;
存储过程需要注意的地方是:用了两次mysql_query($sql);否则执行不成功!
为什么执行不成功?因为用到两次mysql_query(),图一v1不被解析。
转载于:https://blog.51cto.com/okowo/1284463