Publishing a forum post on a web page outside of Moodle

Publishing a forum post on a web page outside of Moodle

by Curtis Quick -
Number of replies: 1
Does anyone know where the data from a given XYZ forum in a given ABC course is stored in a Moodle database? I need to know this so that I can find that data and publish it on a webpage outside Moodle.
Average of ratings: -
In reply to Curtis Quick

Re: Publishing a forum post on a web page outside of Moodle

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hello Curtis,
There are 8 tables related to forums in the Moodle database: forum, forum_discussions, forum_posts, forum_queue, forum_ratings, forum_read, forum_subscriptions and forum_track_prefs.
If this can help, here's an example of a mysql query to retrieve data from a given forum.id 999 in a given course.shortname ABC.
SELECT
    ## course details
    course.shortname,
    ## user details
    u.lastname,
    u.firstname,
    ## forum discussion details
    fo.id,
    fo.name,
    fd.name,
    fd.id,
    ## forum post details
    fp.parent,
    fp.subject,
    fp.message
FROM
    mdl_forum_discussions AS fd,
    mdl_forum_posts AS fp,
    mdl_forum AS fo,
    mdl_user AS u,
    mdl_course AS course
WHERE
    fd.id = fp.discussion
    AND fo.id = 999
    AND fp.userid = u.id
AND course.shortname = 'ABC'
        AND fd.forum = fo.id
    AND fd.course = course.id