Php Chrome页面刷新时运行两次MySQL查询

Php Chrome页面刷新时运行两次MySQL查询,php,mysql,codeigniter,Php,Mysql,Codeigniter,我在一个论坛上工作,现在我想跟踪页面浏览量 我决定在拉入线程内容(OP)的mysql查询之后添加视图更新代码 然而,在Chrome中,numviews值在页面刷新时增加两倍。这在Firefox中不会发生 通常,内容将通过AJAX调用加载,通过这种方式加载时,也不会出现任何问题。在AJAX调用之后,我使用popstate来更改URL,如果用户在页面上刷新,就会出现错误,或者如果用户导航到页面(使用openinnewwindow) 以下是AJAX和非AJAX的控制器代码: 非Ajax线程控制器: p

我在一个论坛上工作,现在我想跟踪页面浏览量

我决定在拉入线程内容(OP)的mysql查询之后添加视图更新代码

然而,在Chrome中,
numviews
值在页面刷新时增加两倍。这在Firefox中不会发生

通常,内容将通过AJAX调用加载,通过这种方式加载时,也不会出现任何问题。在AJAX调用之后,我使用popstate来更改URL,如果用户在页面上刷新,就会出现错误,或者如果用户导航到页面(使用openinnewwindow)

以下是AJAX和非AJAX的控制器代码:

非Ajax线程控制器:

public function threads($threadid)
{
   //...whole lot of other stuff
   $data['content']                 = $this->components_m->thread($threadid);
   $this->load->view('template/template' ,$page);
}
    public function ajax_thread()
    {
        $threadid = $this->input->post('threadid');
        $result['content']              = $this->components_m->thread($threadid);
        echo json_encode($result);
    }
AJAX控制器:

public function threads($threadid)
{
   //...whole lot of other stuff
   $data['content']                 = $this->components_m->thread($threadid);
   $this->load->view('template/template' ,$page);
}
    public function ajax_thread()
    {
        $threadid = $this->input->post('threadid');
        $result['content']              = $this->components_m->thread($threadid);
        echo json_encode($result);
    }
下面是
components\u m->thread($threadid)

我搜索了整个项目,
get\u threads($threadid)
只存在于上面列出的两个函数中

当我使用
$this->output->enable_profiler(TRUE)时我只看到更新函数运行一次

我甚至试着注释出
$result['content']=$this->components\u m->thread($threadid)来自
ajax\u-thread()
并且它在Chrome中仍然更新了两次


有什么想法吗?

通过更改更新sql代码修复了它:

$update = "UPDATE threads SET numviews = numviews + 1 WHERE threadid = $threadid";
$this->db->query($update);