深圳全飞鸿
标题:
beacon的事务处理,transaction
[打印本页]
作者:
zhgc
时间:
2021-5-26 15:48
标题:
beacon的事务处理,transaction
范例一:smttools/st001
$db->BeginTrans(); //开始事务处理
$sqls=array();
$sqls[] ="UPDATE SMT.R_TR_SN SET ext_qty='{$extqty}',location_flag=1,work_flag=0,kitting_flag='a' WHERE TR_SN='{$trsn}'";
$sqls[]="insert into SMT.R_program_log (prg_name,fun_name,action_type,oldsn,out_emp,data1,data2) values('SMTTOOLS','EmptyToFull','空盘下料状态修改','{$trsn}','".$user->empno."','{$extqty}','".this.txt_extqty.Text. "')";
$sqls[]="INSERT INTO smt.r_kitting_scan_detail (tr_sn, cust_kp_no, qty, from_location,to_location, move_type, move_reason, move_emp, move_time) VALUES ('{$trsn}', '{$kp}', '{$extqty}', '{$wo}',".
"'KITTING', 'e', '996', '".$user->empno."', now())";
$sqls[]="UPDATE smt.r_wo_request SET RETURN_QTY = RETURN_QTY + {$extqty} WHERE WO = '{$wo}' AND CUST_KP_NO = '{$kp}' ";
if($smttools->isdebug){
$smttools->saveLog($sqls);
}
$rst=true;
foreach($sqls as $sql){
$rst = $db->execute($sql);
if($rst){
}else{
$res=$db->ErrorMsg();
break;
}
}
if($rst==true){
$rst=false; //可能提交的时候出错!
$db -> CommitTrans();
$rst=true;
}else{
$db -> RollbackTrans();
}
return $rst;
复制代码
作者:
syant
时间:
2025-5-29 12:34
//处理数据库连接
$this->app->prepare_mes();
//开始处理修改数据
$sqls=array();
$sqls[] ="update smt.c_stencil_base set work_flag=1,check_time=now() where stencil_sn='{$trsn}'";
$sqls[] ="insert into smt.c_stencil_list select * from smt.c_stencil_base where stencil_sn='{$trsn}'";
//开始事务处理
$this->app->mes->BeginTrans();
$rst=true;
foreach($sqls as $sql){
$rst = $this->app->mes->execute($sql);
if($rst){
}else{
$res=$this->app->mes->ErrorMsg();
$this->app->AjaxFail("{$res},{$sql}", 100);
break;
}
}
//开始提交
if($rst==true){
$this->app->mes -> CommitTrans();
}else{
$this->app->mes -> RollbackTrans();
return;
}
//要取消AjaxOK,改为AjaxPass函数,因为AjaxPass和AjaxFail保持一样的参数顺序
$this->app->AjaxOK($trsninfo,"钢网{$trsn}收入工具室!");
复制代码
欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/)
Powered by Discuz! X3.2