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

$this->db->insert()执行了2遍,什么情况?

[复制链接]
发表于 2013-12-3 17:37:24 | 显示全部楼层 |阅读模式
本帖最后由 qiguojie 于 2013-12-3 17:38 编辑
PHP复制代码
 
        function init($user_id){
                $now=time();
                $now_time=unix_to_human($now,TRUE,'eu');
                $data = Array(
                        "user_id"=>$user_id,
                        "type"=>1,
                        "num"=>0,
                        "create_time"=>$now_time
                );
                $this->db->insert($this->TABLE,$data);
 
复制代码


调用:
$re = $this->user_model->init(1);
var_dump($re);

结果数据库中,执行了2次insert操作。
15        1        1                0                        2013-12-03 17:28:07
16        1        1                0                        2013-12-03 17:28:08


这是为什么呢??
发表于 2013-12-4 13:03:37 | 显示全部楼层
肯定是你哪里调用了两次。
不可能无中生有执行两次。
发表于 2013-12-4 14:56:42 | 显示全部楼层
发出全文代码!
发表于 2013-12-4 21:17:46 | 显示全部楼层
init会自动调用一次,然后你手动调用了一下吧
 楼主| 发表于 2013-12-19 15:54:50 | 显示全部楼层
可能是环境的问题,我在公司的环境,就会执行2次,回家同样的代码就只执行一次。。

本版积分规则