Hi,
If I'm trying to find the most recent open visible thread with a tag (ID or Url whatever is better?)
Is the best way like below to just hit the thread table searching the tag blob using the tag_url/tag_id?
Or should I be joining with the tag table and finding based on the tag_ID?
Just hitting the thread table
Or should I be joining with the tag_content table
If I'm trying to find the most recent open visible thread with a tag (ID or Url whatever is better?)
Is the best way like below to just hit the thread table searching the tag blob using the tag_url/tag_id?
Or should I be joining with the tag table and finding based on the tag_ID?
Just hitting the thread table
Code:
$this->app->finder('XF:Thread')
->where('tag', 'LIKE', $finder->escapeLike($tag_url, '%?%'))
->where('discussion_state', '=', 'visible')
->where('discussion_open', '=', 1)
->fetchOne();
Or should I be joining with the tag_content table
Code:
$finder->sqlJoin('(
select content_id as thread_id
from xf_tag_content
where content_type = \'thread\' and tag_id in (' . $db->quote($tagIds) . ')
group by content_id
having count(*) >= '. $db->quote(count($tagIds)) .'
)', 'taggedThread', ['thread_id'], true, true);
$finder->sqlJoinConditions('taggedThread', ['thread_id']);