php mysql 存储过程实例
2010-10-07 05:10
591 查看
PHP与MySQL存储过程 实例一:无参的存储过程
创建一个myproce的存储过程
$sql = "call test.myproce();";
MySQL_query($sql);
调用myproce的存储过程,则数据库中将增加一条新记录。
PHP与MySQL存储过程 实例二:传入参数的存储过程
创建一个myproce2的存储过程
$sql = "call test.myproce2(70);";
MySQL_query($sql);
调用myproce2的存储过程,看不到效果,可以在cmd下看到结果。
PHP与MySQL存储过程 实例三:传出参数的存储过程
创建一个myproce3的存储过程
$sql = "call test.myproce3(@score);";
MySQL_query($sql);
调用myproce3的存储过程
存储过程 实例四:传出参数的inout存储过程
创建一个myproce4的存储过程
$sql = "set @sexflag = 1";
MySQL_query($sql); 设置性别参数为1
$sql = "call test.myproce4(@sexflag);";
MySQL_query($sql);
调用myproce4的存储过程,在cmd下面看效果
转载自 http://tech.ccidnet.com/art/1108/20100722/2125793_1.html
$conn = MySQL_connect('localhost','root','root') or die ("数据连接错误!!!"); MySQL_select_db('test',$conn); $sql = " create procedure myproce() begin INSERT INTO user (id, username, sex) VALUES (NULL, 's', '0'); end; "; MySQL_query($sql); |
$sql = "call test.myproce();";
MySQL_query($sql);
调用myproce的存储过程,则数据库中将增加一条新记录。
PHP与MySQL存储过程 实例二:传入参数的存储过程
$sql = " create procedure myproce2(in score int) begin if score >= 60 then select 'pass'; else select 'no'; end if; end; "; MySQL_query($sql); |
$sql = "call test.myproce2(70);";
MySQL_query($sql);
调用myproce2的存储过程,看不到效果,可以在cmd下看到结果。
PHP与MySQL存储过程 实例三:传出参数的存储过程
$sql = " create procedure myproce3(out score int) begin set score=100; end; "; MySQL_query($sql); |
$sql = "call test.myproce3(@score);";
MySQL_query($sql);
调用myproce3的存储过程
$result = MySQL_query('select @score;'); $array = MySQL_fetch_array($result); echo '<pre>';print_r($array); PHP与MySQL |
$sql = " create procedure myproce4(inout sexflag int) begin SELECT * FROM user WHERE sex = sexflag; end; "; MySQL_query($sql); |
$sql = "set @sexflag = 1";
MySQL_query($sql); 设置性别参数为1
$sql = "call test.myproce4(@sexflag);";
MySQL_query($sql);
调用myproce4的存储过程,在cmd下面看效果
转载自 http://tech.ccidnet.com/art/1108/20100722/2125793_1.html
相关文章推荐
- mysql存储过程详解以及PHP调用MYSQL存储过程实例
- PHP调用MYSQL存储过程实例
- PHP调用MYSQL存储过程实例
- php调用mysql存储过程实例分析
- 基于Php mysql存储过程的实例
- PHP调用MYSQL存储过程实例
- PHP调用MYSQL存储过程实例
- PHP调用MYSQL存储过程实例
- PHP调用MYSQL存储过程实例
- PHP调用MYSQL存储过程实例
- PHP调用MYSQL存储过程实例
- PHP调用MySQL存储过程实例
- PHP和MySQL存储过程的实例演示
- PHP调用MYSQL存储过程实例
- PHP调用MYSQL存储过程实例
- PHP调用MYSQL存储过程实例
- PHP调用MYSQL存储过程实例
- PHP调用MYSQL存储过程实例
- php调用mysql存储过程实例分析
- PHP调用MySQL存储过程实例