2013-04-19, 08:29 AM
I'm Making a class that Integrates Yii with MyBB. So Far the Class is working fine and I can login/Logout and use MyBB as primary login System. Now I want to get latest posts from certain Forums. The first thing was to query all forums and it does not work. Here is the code I use.
What do I do wrong? Connection is fine and no error is thrown!
It works fine, it was data issue. Now, how do I limit forum IDs to those which all registered users are allowed (there are forums that are exclusive to staffs).
Thanks!
What do I do wrong? Connection is fine and no error is thrown!
$query = $this->_db->query("
SELECT t.*, u.username
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
WHERE 1=1 AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
ORDER BY t.lastpost DESC
LIMIT 0, 6" // Change the last digit to how many recent post you want to be shown
);
$list = '';
while($fetch = $this->_db->fetch_array($query))
{
$list .= "<strong><a href=\"forums/showthread.php?tid={$fetch['tid']}\">".htmlspecialchars_uni($fetch['subject'])."</a></strong><br />";
$poster = "<a href=\"forums/member.php?action=profile&uid=".$fetch['uid']."\">{$fetch['username']}</a>";
$list .= "Created by: {$poster}<br />";
$list .= "<i>" .$fetch['replies']. " Replies</i>";
$list .= "<i> , " .$fetch['views']. " Views</i><br />";
$list .= " (<i>Last post by: " .$fetch['lastposter']. "</i>)<br /><hr width=\"50\"><br />";
}
It works fine, it was data issue. Now, how do I limit forum IDs to those which all registered users are allowed (there are forums that are exclusive to staffs).
Thanks!