MySQL field plus 1 error

Source: Internet
Author: User
Many days ago discovered the problem, at that time thought is oneself machine problem, now upload cloud server still can't solve, hope big God help me ~
First of all, my personal blog post has a look field in MySQL, each time you view this blog, this field will add 1 to the original value, but the problem is that I always click to see it is the original value plus 2, which really makes me puzzled, see the source

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 controller of the source fragment, has determined that the Viewblog () function is only executed once, and more bizarre is if I click on the comments (comments and views compared to a tag only a #anchor anchor point to the comment box) Its look value will be added 3, and then click on the view or comment it will be normal add 1 ...
Ask the big God to tell the personal blog This is my blog address, not to ask for visits, really ask God ~ ~ ~ ~

Reply content:

Many days ago discovered the problem, at that time thought is oneself machine problem, now upload cloud server still can't solve, hope big God help me ~
First of all, my personal blog post has a look field in MySQL, each time you view this blog, this field will add 1 to the original value, but the problem is that I always click to see it is the original value plus 2, which really makes me puzzled, see the source

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 controller of the source fragment, has determined that the Viewblog () function is only executed once, and more bizarre is if I click on the comments (comments and views compared to a tag only a #anchor anchor point to the comment box) Its look value will be added 3, and then click on the view or comment it will be normal add 1 ...
Ask the big God to tell the personal blog This is my blog address, not to ask for visits, really ask God ~ ~ ~ ~

You don't have to go directly into the database first, test it look = look +1 Isn't there a problem here to see if it's really visited once

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.