1

我试图通过在数据库中增加它来更新特定页面的视图。这是代码:

function increment_views($id)
{
    $this->db->where('UID',$id);
    $this->db->set('`Views`', 'Views+1', FALSE);
    if($this->db->update('articles'))
        return true;
    else
        return false;
}

当我在控制器中回显某些内容时,它会更新 1 次(按原意)。如果我只是加载我的视图并在控制器中不回显任何内容,它会更新视图 4 次,有时甚至 5 次。

编辑:发现问题。当 url 有一个斜杠时,增量是异常的,否则它只会增加 1。问题是我需要尾部斜杠才能使 disqus 插件工作。这是我的 .htaccess 文件:

#turn mod_rewrite engine on.
RewriteEngine On
#set the base for urls here to /
RewriteBase /codzer

#adds a trailing slash
RewriteCond %{REQUEST_URI} !(/$|\.) 
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L] 


### if the is not a request for an existing file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# rewrite to index.php passing the URI as a path, QSA will preserve the existing query string
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

知道我可能错在哪里吗?

谢谢

4

0 回答 0