Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Jade Elizabeth on September 23, 2012, 01:48:16 PM

Title: Query_See_Board Issues
Post by: Jade Elizabeth on September 23, 2012, 01:48:16 PM
I get this error after using Query_See_Board: Database Error: Unknown column 'b.member_groups' in 'where clause'

Code: [Select]
$request = $smcFunc['db_query']('', '
SELECT m.subject, t.id_topic
FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}messages AS m ON m.id_topic = t.id_topic
WHERE t.id_board IN({raw:inc_boards})
AND {query_see_board}
GROUP BY t.id_topic
ORDER BY t.id_topic {raw:sort}
LIMIT 0,{int:num_topics}',

array(
'num_topics' => (int) $num_topics,
'inc_boards' => implode(',', $inc_boards),
'sort' => $sort,
)
);

I'm not familiar with anything like this so is there a different variable I should use?
Title: Re: Query_See_Board Issues
Post by: NanoSector on September 23, 2012, 02:00:09 PM
That's the wrong query, sorry, try enabling the setting that shows queries in the error log (nfi how it's called)
Title: Re: Query_See_Board Issues
Post by: emanuele on September 23, 2012, 02:05:12 PM
Try:
Code: [Select]
$request = $smcFunc['db_query']('', '
SELECT m.subject, t.id_topic
FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic)
LEFT JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
WHERE t.id_board IN ({array_int:inc_boards})
AND {query_see_board}
GROUP BY t.id_topic
ORDER BY t.id_topic {raw:sort}
LIMIT 0,{int:num_topics}',

array(
'num_topics' => (int) $num_topics,
'inc_boards' => $inc_boards,
'sort' => $sort,
)
);

But exactly what are you trying to obtain? (since I feel there is a better way to do it)

ETA: @Yoshi: the query is wrong anyway because {query_see_board} wants the table {db_prefix}boards somewhere in the query. ;)
Title: Re: Query_See_Board Issues
Post by: Jade Elizabeth on September 23, 2012, 02:37:28 PM
It's SSI Recent topics lol...

Was going to do a bug report, it should have query see board in it already. Trying what you said but here's the whole function (I copied it and edited it to have topics only or something I can't remember).

Code: [Select]
function BRSrecentTopics($num_topics, $inc_boards, $sort)
{
// Need $smcFunc, but make sure SSI.php is included BEFORE this is called)
global $smcFunc;
$request = $smcFunc['db_query']('', '
SELECT m.subject, t.id_topic
FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}messages AS m ON m.id_topic = t.id_topic
WHERE t.id_board IN({raw:inc_boards})
AND {query_see_board}
GROUP BY t.id_topic
ORDER BY t.id_topic {raw:sort}
LIMIT 0,{int:num_topics}',

array(
'num_topics' => (int) $num_topics,
'inc_boards' => implode(',', $inc_boards),
'sort' => $sort,
)
);

while ($row = $smcFunc['db_fetch_assoc']($request))
$topics[] = array(
'subject' => $row['subject'],
'id' => $row['id_topic'],
'link' => '<a href="http://www.bunnyrabbitsex.com/index.php?topic=' . $row['id_topic'] . '">' . $row['subject'] . '</a>',
);

return $topics;

}
Title: Re: Query_See_Board Issues
Post by: Jade Elizabeth on September 23, 2012, 02:40:29 PM
Doesn't seem to be throwing errors, will let you know again tomorrow! <3


Also if you're talking about eval, it's not an issue on my forums ;).