|
本帖最后由 visvoy 于 2009-8-26 17:01 编辑
不知道下面哪写错了,有些sql执行失败时,不能回滚PHP复制代码
function updategroup (){
$this->db->trans_begin();
$data1=array('g_name'=>$this->input->post('groupname'));
$this->db->where('g_id',$this->input->post('g_id'));
$this->db->update('groups',$data1);
$id=$this->input->post('g_id');
$sql="delete from `menu_group` where `g_id`='$id'";
$this->db->query($sql);
$bmenu=array();
$bmenu=$this->input->post('bigmenu');
if(!empty($bmenu)){
foreach($bmenu as $value){
$datab=array('g_id'=>$this->input->post('g_id'),'m_id'=>$value,'m_parent_id'=>0);
$query1=$this->db->insert('menu_group',$datab);
}
}
$smenu=array();
$smenu=$this->input->post('smenu');
if(!empty($smenu)){
foreach($smenu as $value){
$smenu1=explode(',',$value);
$smenuid=$smenu1[0];
$bmenuid=$smenu1[1];
$datas=array('g_id'=>$this->input->post('g_id'),'m_id'=>$smenuid,'m_parent_id'=>$bmenuid);
$query2=$this->db->insert('menu_group',$datas);
}
}
if ($this->db->trans_status() === FALSE){
$this->db->trans_rollback();
return false;
}
else{
$this->db->trans_commit();
return true;
}
}
复制代码 |
|