例如
create procedure p_a1(in p_id int,in p_name varchar(20),out p_out varchar(200))
begin
declare p_cm int
set p_cm = 0
insert into a1(id,name) values(p_id,p_name)
select row_count() into p_cm
if (p_cm = 1)
then
set p_out = '成功'
else
set p_out = '不成功'
end if
end
mysql>call p_a1(5,'KK',@a2)//
Query OK, 1 row affected (0.01 sec)
mysql>select @a2//
+--------+
| @a2|
+--------+
| 成功 |
+--------+
1 row in set (0.01 sec)
以上来自手打,希望对你有帮助!呵呵~
function func($val,$id) {$sql="update table set a=? where id=?"
$pre=$this->pdo->prepare($sql)
$this->pdo->beginTransaction()//开启事务
$bo=$pre->execute(array($val,$id))
if($bo){
//…执行代码……
$this->pdo->commit()//提交事务
return true
}else{
//…执行代码……
$this->pdo->rollBack()//回滚事务
return false
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)