Commit 8cd05426 authored by Francois Marier's avatar Francois Marier
Browse files

Move constant parameters directly into the queries


Signed-off-by: default avatarFrancois Marier <francois@catalyst.net.nz>
parent a8129be9
...@@ -65,11 +65,11 @@ else { // edit topic ...@@ -65,11 +65,11 @@ else { // edit topic
$forum = get_record_sql( $forum = get_record_sql(
'SELECT f.group AS groupid, f.title, g.name AS groupname, g.grouptype, ic.value AS newtopicusers 'SELECT f.group AS groupid, f.title, g.name AS groupname, g.grouptype, ic.value AS newtopicusers
FROM {interaction_instance} f FROM {interaction_instance} f
INNER JOIN {group} g ON (g.id = f.group AND g.deleted = ?) INNER JOIN {group} g ON (g.id = f.group AND g.deleted = 0)
LEFT OUTER JOIN {interaction_forum_instance_config} ic ON (f.id = ic.forum AND ic.field = \'createtopicusers\') LEFT OUTER JOIN {interaction_forum_instance_config} ic ON (f.id = ic.forum AND ic.field = \'createtopicusers\')
WHERE f.id = ? WHERE f.id = ?
AND f.deleted != ?', AND f.deleted != 1',
array(0, $forumid, 1) array($forumid)
); );
if (!$forum) { if (!$forum) {
throw new NotFoundException(get_string('cantfindforum', 'interaction.forum', $forumid)); throw new NotFoundException(get_string('cantfindforum', 'interaction.forum', $forumid));
......
...@@ -44,13 +44,13 @@ $topic = get_record_sql( ...@@ -44,13 +44,13 @@ $topic = get_record_sql(
'SELECT p.subject, p.poster, p.id AS firstpost, ' . db_format_tsfield('p.ctime', 'ctime') . ', t.id, f.group AS groupid, g.name AS groupname, f.id AS forumid, f.title AS forumtitle, t.closed, sf.forum AS forumsubscribed, st.topic AS topicsubscribed 'SELECT p.subject, p.poster, p.id AS firstpost, ' . db_format_tsfield('p.ctime', 'ctime') . ', t.id, f.group AS groupid, g.name AS groupname, f.id AS forumid, f.title AS forumtitle, t.closed, sf.forum AS forumsubscribed, st.topic AS topicsubscribed
FROM {interaction_forum_topic} t FROM {interaction_forum_topic} t
INNER JOIN {interaction_instance} f ON (t.forum = f.id AND f.deleted != 1) INNER JOIN {interaction_instance} f ON (t.forum = f.id AND f.deleted != 1)
INNER JOIN {group} g ON (g.id = f.group AND g.deleted = ?) INNER JOIN {group} g ON (g.id = f.group AND g.deleted = 0)
INNER JOIN {interaction_forum_post} p ON (p.topic = t.id AND p.parent IS NULL) INNER JOIN {interaction_forum_post} p ON (p.topic = t.id AND p.parent IS NULL)
LEFT JOIN {interaction_forum_subscription_forum} sf ON (sf.forum = f.id AND sf.user = ?) LEFT JOIN {interaction_forum_subscription_forum} sf ON (sf.forum = f.id AND sf.user = ?)
LEFT JOIN {interaction_forum_subscription_topic} st ON (st.topic = t.id AND st.user = ?) LEFT JOIN {interaction_forum_subscription_topic} st ON (st.topic = t.id AND st.user = ?)
WHERE t.id = ? WHERE t.id = ?
AND t.deleted != 1', AND t.deleted != 1',
array(0, $USER->get('id'), $USER->get('id'), $topicid) array($USER->get('id'), $USER->get('id'), $topicid)
); );
if (!$topic) { if (!$topic) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment