Hello,
I can write the query I want in standard SQL fine:
although I'm struggling to work out how to rewrite it for XF2 to use the finder function, this is my current stab and I think I'm far off.
Could anyone give me any help? thanks
I can write the query I want in standard SQL fine:
Code:
SELECT * FROM xf_tagess_tag_watch, xf_tag_content, xf_thread where xf_tagess_tag_watch.user_id = @userid
and xf_tag_content.tag_id = xf_tagess_tag_watch.tag_id
and xf_tag_content.content_id = xf_thread.thread_id
and xf_thread.discussion_open = 1
and xf_thread.discussion_state = 'visible'
order by xf_thread.last_post_date DESC
although I'm struggling to work out how to rewrite it for XF2 to use the finder function, this is my current stab and I think I'm far off.
Could anyone give me any help? thanks
Code:
$finder
->with('fullForum')
->where('discussion_state', 'visible')
->sqlJoin('xf_tag_content', 'synonym', ['xf_tag_content.content_id','xf_thread.thread_id'], false)
->sqlJoinConditions('synonym', [['xf_tag_content.content_id', '=', '$xf_thread.thread_id']])
->sqlJoin('xf_tagess_tag_watch', 'synonym2', ['xf_tag_content.tag_id','xf_tagess_tag_watch.tag_id'], false)
->sqlJoinConditions('synonym2', [['xf_tag_content.tag_id', '=', 'xf_tagess_tag_watch.tag_id']])
->where('xf_tagess_tag_watch.user_id', $userId)
->setDefaultOrder('last_post_date', 'DESC');