用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2618|回复: 3
收起左侧

[已解决] 为什么我的更新操作一定要执行两遍才有效果?

[复制链接]
发表于 2011-4-20 16:40:22 | 显示全部楼层 |阅读模式
PHP复制代码
 
$this->load->database();
$this->db->trans_start();
$data = array(
                        'name'        => $this->input->post('name'),
                        'type'        => $this->input->post('type'),
                        'province'    => $this->input->post('province'),
                        'city'        => $this->input->post('city'),
                        'county'      => $this->input->post('county'),
                        'first_money' => $this->input->post('first_money'),
                        'year_money'  => $this->input->post('year_money'),
                        'margin'      => $this->input->post('margin'),
                        'period'      => $this->input->post('period'),
                        'start_date'  => $this->input->post('start_date'),
                        'end_date'    => $this->input->post('end_date')
                );     
                $this->db->where('id',$id);
                $this->db->update($this->c_table,$data);
//              $this->_edit_ext();
                ($this->db->trans_status() === FALSE)?
                        $act=FALSE :
                        $act=TRUE ;
                return $act;
 
复制代码


上面是代码片段,一定要执行两遍 数据库里面的数据才有变化。我开启了调试功能 但是第一次执行的时候显示执行了SQL语句,就是数据库里没有效果!
 楼主| 发表于 2011-4-21 09:18:09 | 显示全部楼层
都没有人啊?求助啊!
发表于 2011-4-21 09:20:33 | 显示全部楼层
你用事物,你只是start了,没$this->db->trans_complete();,就是没有commit???
 楼主| 发表于 2011-4-21 10:45:02 | 显示全部楼层
回复 3# jeongee


      多谢高手!

本版积分规则