YIi调用mysql的stored procedure

1. 创建stored procedure

delimiter //
create procedure retval(in c int)
begin
select * from users where id=c;
end //
delimiter ;

2. 从php调用

 17 $id = 3;
 18 $cmd=Yii::app()->db->createCommand(‘call retval(‘ . $id  .  ‘)’);
 19 $rows=$cmd->queryAll();
 20 foreach( $rows as $row )
 21 {   
 22     echo $row[‘id’] . ‘-‘ . $row[‘username’];
 23 }

版权所有,禁止转载. 如需转载,请先征得博主的同意,并且表明文章出处,否则按侵权处理.

    分享到:

Leave a Reply

Your email address will not be published. Required fields are marked *