I found a problem many days ago. I thought it was my machine problem. I still cannot solve the problem after I uploaded my ECs instance. Hope you can help me ~ First, my blog post has a Look field in Mysql. Every time I view this blog, I add 1 to the original value. But the problem is that I click to view it every time... I found a problem many days ago. I thought it was my machine problem. I still cannot solve the problem after I uploaded my ECs instance. Hope you can help me ~
First, my blog post has a Look field in Mysql. Each time I view this blog, this field is added to the original value by 1, but the problem is that I always add 2 to the original value every time I click to view it. This is really confusing to me. Check the source code.
public function viewBlog(){ $_sql='SELECT * FROM blog WHERE id='.$this->_id.' AND verify=1'; $_sqlView='UPDATE blog SET `look`=`look`+1 WHERE id='.$this->_id; parent::aud($_sqlView); return parent::getOne($_sql); }
This is the source code in the Model.
private function viewBlog(){ $this->_model->_id=Tool::checkInt(@$_GET['id']); $_oneBlog=$this->_model->viewBlog(); $this->_tpl->assign('oneBlog',$_oneBlog);
This is the source code snippet of the controller. It has been confirmed that the viewBlog () function is only executed once, what's more strange is that if I click a comment (the comment and view are only one more # anchor is located in the comment box), its look value will be increased by 3, then, click View or comment on it to add 1 to it ......
Please tell your blog that this is my blog address, not the access traffic ~~~
Reply content:
I found a problem many days ago. I thought it was my machine problem. I still cannot solve the problem after I uploaded my ECs instance. Hope you can help me ~
First, my blog post has a Look field in Mysql. Each time I view this blog, this field is added to the original value by 1, but the problem is that I always add 2 to the original value every time I click to view it. This is really confusing to me. Check the source code.
public function viewBlog(){ $_sql='SELECT * FROM blog WHERE id='.$this->_id.' AND verify=1'; $_sqlView='UPDATE blog SET `look`=`look`+1 WHERE id='.$this->_id; parent::aud($_sqlView); return parent::getOne($_sql); }
This is the source code in the Model.
private function viewBlog(){ $this->_model->_id=Tool::checkInt(@$_GET['id']); $_oneBlog=$this->_model->viewBlog(); $this->_tpl->assign('oneBlog',$_oneBlog);
This is the source code snippet of the controller. It has been confirmed that the viewBlog () function is only executed once, what's more strange is that if I click a comment (the comment and view are only one more # anchor is located in the comment box), its look value will be increased by 3, then, click View or comment on it to add 1 to it ......
Please tell your blog that this is my blog address, not the access traffic ~~~
Do not directly store the data in the database first, test it.look=look+ 1 is there a problem here. Check if the access is actually performed once.