Hash tags - marcus123 - 2015-08-05
I have created this plugin but man it generates a ton of queries not sure why??? I am using array to decrease them but some is wrong??
$pids = array();
$querysearch = $db->query("
SELECT *
FROM ".TABLE_PREFIX."posts p
LEFT JOIN " . TABLE_PREFIX . "threads t ON(p.tid=t.tid)
WHERE p.message LIKE '%".$search."%' AND t.visible='1' AND t.closed NOT LIKE 'moved|%' {$where}
order by p.tid
LIMIT {$start}, {$perpage}
");
while($whiletag = $db->fetch_array($querysearch))
{
$forumpermissions[$whiletag['fid']] = forum_permissions($whiletag['fid']);
// Make sure we can view this thread
if($forumpermissions[$whiletag['fid']]['canview'] == 0 || $forumpermissions[$whiletag['fid']]['canviewthreads'] == 0 || $forumpermissions[$whiletag['fid']]['canonlyviewownthreads'] == 1 && $whiletag['uid'] != $mybb->user['uid'])
{
continue;
}
$pids[] = $whiletag['pid'];
}
foreach($pids as $pid)
{
$posts = get_post($pid);
if(strlen($posts['subject']) > "85")
{
$postsubject = htmlspecialchars_uni(my_substr($posts['subject'],0,82)."...");
}
else
{
$postsubject = htmlspecialchars_uni($posts['subject']);
}
if(strlen($posts['message']) > "55")
{
$postmessage = htmlspecialchars_uni(my_substr($posts['message'],0,52)."...");
}
else
{
$postmessage = htmlspecialchars_uni($posts['message']);
}
$fid = get_forum($posts['fid']);
$tid = get_thread($posts['tid']);
$threadurl = "<a target=\"_blank\" href=\"".$mybb->settings['bburl']."/".get_thread_link($posts['tid'])."\">".$tid['subject']."</a>";
$forumurl = "<a target=\"_blank\" href=\"".$mybb->settings['bburl']."/".get_forum_link($posts['fid'])."\">".$fid['name']."</a>";
$userurl = build_profile_link($posts['username'], $posts['uid']);
$postlink = "<a target=\"_blank\" href=\"".$mybb->settings['bburl']."/".get_post_link($posts['pid'])."#pid".$posts['pid']."\">".$postsubject."</a>";
$postdate = my_date($mybb->settings['dateformat'], $posts['postdate']) . '<br/>' . my_date($mybb->settings['timeformat'], $posts['postdate']);
echo "<div style=\"text-align:left;\">".$postlink."</div>";
eval("\$listhreads .= \"".$templates->get("tags_listthread")."\";");
}
RE: Hash tags - Destroy666 - 2015-08-05
That's why:
$posts = get_post($pid);
$tid = get_thread($posts['tid']); Use LEFT JOINs instead.
RE: Hash tags - marcus123 - 2015-08-05
Thanks buddy I really though about that thanks for conforming it +1
|