Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How would you count discussions and comments?

edited October 2006 in Vanilla 1.0 Help
I'm working on an extension but want to build it so that it doesn't cause performance problems. Is there a good way to get the grand total number of discussions and comments? I've looked at the PanelCategories extension and can use that technique to get the counts by category. But what I would like to get is the grand total before I would go into the category loop so that I can analyze the categories. I would appreciate any advice as to where to look? Thanks, jim


  • Options
    edited October 2006
    Comments count:SELECT count(*) FROM LUM_Comment WHERE deleted = '0'

    Discussions count:SELECT count(*) FROM LUM_Discussion WHERE CategoryID = 'x'

    Replace x with whatever category you want to check in. Remove the where line to check all categories. There was a post a couple months back where Mark described a quick way to run SQL--
  • Options
    If you're doing this on the discussions page that information may already be available as it's displayed at the top of the screen. I gotta run so cant dig around but it's worth checking out.
  • Options
    I never thought about the simple sql commands. Thank you. But now another concern. I don't think I want to execute those queries each time the discussions page is clicked. It would seem to me that I would only want to run those queries if a new discussion or comment were added to the database. Does Vanilla keep the discussiodID or commentID in memory so that I could access it? Or is there another technique I should use?
This discussion has been closed.