2核1G3M服务器88一季度

腾讯云,阿里云百度云等 折扣价→点我←

discuz x3.4我收藏的版块和帖子、文章、日志、群组的查询 discuz 教程

游客1 游客组




因为有些常用的帖子和版块每次都要点来点去的去找,所以干脆把收藏功能拿出来用,做个菜单,随时查看和删除。 查询代码:

1.我收藏的版块
$forum_favorites = DB::fetch_all("SELECT a.*,b.name,b.todayposts,c.icon,c.description as forum_description FROM ".DB::table('home_favorite')." a LEFT JOIN ".DB::table('forum_forum')." b on b.fid=a.id LEFT JOIN ".DB::table('forum_forumfield')." c on c.fid=b.fid WHERE a.`idtype`= 'fid' AND a.`uid`='$_G[uid]' ORDER BY a.`dateline` DESC LIMIT 0,10");//版块


2.我收藏的帖子
$thread_favorites = DB::fetch_all("SELECT a.*,b.authorid,b.author,b.views,b.replies,b.tid,c.attachment,c.remote FROM ".DB::table('home_favorite')." a LEFT JOIN ".DB::table('forum_thread')." b on b.tid=a.id LEFT JOIN ".DB::table('forum_threadimage')." c on c.tid=b.tid WHERE a.`idtype`= 'tid' AND a.`uid`='$_G[uid]' ORDER BY a.`dateline` DESC LIMIT 0,10");//帖子


3.我收藏的文章
$article_favorites = DB::fetch_all("SELECT * FROM ".DB::table('home_favorite')." a LEFT JOIN ".DB::table('portal_article_title')." b on b.aid=a.id WHERE a.`idtype`= 'aid' AND a.`uid`='$_G[uid]' ORDER BY a.`dateline` DESC LIMIT 0,20");//文章


4.我收藏的群组
$groups_favorites = DB::fetch_all("SELECT a.*,b.*,c.description as forum_description FROM ".DB::table('home_favorite')." a LEFT JOIN ".DB::table('forum_forum')." b on b.fid=a.id LEFT JOIN ".DB::table('forum_forumfield')." c on c.fid=b.fid WHERE a.`idtype`= 'gid' AND a.`uid`='$_G[uid]' ORDER BY a.`dateline` DESC LIMIT 0,20");//群组


5.我收藏的日志
$blogs_favorites = DB::fetch_all("SELECT * FROM ".DB::table('home_favorite')." a LEFT JOIN ".DB::table('home_blog')." b on b.blogid=a.id LEFT JOIN ".DB::table('home_blogfield')." c on c.blogid=a.id WHERE a.`idtype`= 'blogid' AND a.`uid`='$_G[uid]' ORDER BY a.`dateline` DESC LIMIT 0,20");//日志


可被收藏的就这些了吧。 这里只是列出20条,像帖子、文章、日志这种可能会收藏很多,如果有分页需要可以利用自带的分页函数来分页。



20190919 补充调用方法
{loop $forum_favorites $value} $value['字段'] {/loop}

{loop $thread_favorites $value} $value['字段'] {/loop}


20180919 补充文章、日志、群组的查询
站长窝论坛版权声明 1、本帖标题:discuz x3.4我收藏的版块和帖子、文章、日志、群组的查询
2、论坛网址:站长窝论坛
3、站长窝论坛的资源部分来源于网络,如有侵权,请联系站长进行删除处理。
4、会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。
5、站长窝论坛一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
6、本帖由游客1在站长窝论坛《程序综合区》版块原创发布, 转载请注明出处!
评论
最新回复 (0)
返回
发新帖