Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    May 2012
    Posts
    45
    Thanks
    7
    Thanked 1 Time in 1 Post

    Set PHPbb Thread View Numbers

    Code:
    UPDATE  `phpbb_topics` SET  `topic_views` =  '145' WHERE  `topic_id` =1
    This is the code you get when manually editing a single post's view count in phpMyAdmin, and the topic ID is 1.

    What I am needing to do, is to edit all posts at once, and instead of setting the views of every topic to 145, I want to add 145 to every thread's number of topic views. Make sense?

    I know that

    Code:
    UPDATE  `phpbb_topics` SET  `topic_views` =  '145' WHERE  `topic_id` >=1
    Would set the topic views of all posts to 145.

    SO my question, is there (and if so, what is) the MySQL command to increase the number of topic views by a number I specify rather than to set the number of topic views on all threads to a specific number.

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,537
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Well, just like how with any other programming language a variable set to itself + an amount would work, the same applies here

    Code:
    UPDATE  `phpbb_topics` SET  `topic_views` = topic_views + 145
    As topic_views is (or should be) a numeric type (int I'm guessing?), don't quote it... 145 != '145'

  • Users who have thanked Keleth for this post:

    iT3d. (06-28-2012)

  • #3
    New Coder
    Join Date
    May 2012
    Posts
    45
    Thanks
    7
    Thanked 1 Time in 1 Post
    As topic_views is (or should be) a numeric type (int I'm guessing?), don't quote it... 145 != '145'
    I just did a manual edit and copied everything phpMyAdmin returned to me - but thanks for the input ill remember that for the future.


    That worked! I'l have to bring in a WHERE to specify specifics but that worked wondefully thank you!

  • #4
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    well you said you wanted it to apply to all topic_views so you wouldn't need a WHERE clause to affect all topic_views.

    you shouldn't quote numeric values no, but mysql allows you to be sloppy and do so. I'd advise not to get in that habit though.

  • #5
    New Coder
    Join Date
    May 2012
    Posts
    45
    Thanks
    7
    Thanked 1 Time in 1 Post
    Quote Originally Posted by guelphdad View Post
    well you said you wanted it to apply to all topic_views so you wouldn't need a WHERE clause to affect all topic_views.
    To boost the views as a whole, but I don't want everything to appear to uniform in the end so i'll have to make use of a WHERE to differentiate and make the stats look legit.

    Quote Originally Posted by guelphdad View Post
    you shouldn't quote numeric values
    Good to know, a definite note hath been made of this. Thank you.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •