New to plugin coding, need to know if I can do this.
For a website I'm working on, I'm tying together the news posts with MyBB threads to make up a comments system.

I've already gotten the commenting bit working, but so I don't need to query the database each time I need to check the number of comments, I want to save the value in the news story database.

I've already implemented this code in my add comment function on the site-end, but I need to do the same if a user posts a comment through the forum. I assume if I use one of the newreply hooks (haven't looked at which one I'll need yet), I'll have access to the tid and can do the SQL queries I need?

One question I have is the $db->query() code --- how would I grab the SQL results from that? Here's a synopsis of the code I'm trying to do:

- Take tid and check to see if any of the news stories have the same value.
- If so, increment the comments count for that news story.

The actual SQL is simple, but I'm not used to how MyBB works.
Is this connected to the thread? If so a simple $db->simple_select("threads", "replies", "tid="'.$tid.'"); would do it.

MyBB already stores the reply number in threads table.

Not sure how your comments system is directly related to the threads/posts tables.
I have a "forumurl" field in the news table, which corresponds to a tid on MyBB's database.

I was needing to store the replies # on the news table since I have filters like "Most Comments", and it'd be a waste having to query two databases each time when I could just query the news table.

Essentially, I'm just needing to add some code to MyBB's existing new_reply function to increment the comment count in the news table if that tid exists in the forumurl field.

Forum Jump:

Users browsing this thread: 1 Guest(s)