dz我收藏的版块和帖子查询

[复制链接]
查看3807 | 回复0 | 2019-1-15 11:15:54 | 显示全部楼层 |阅读模式
本帖最后由 技术控 于 2019-1-15 11:24 编辑

因为有些常用的帖子和版块每次都要点来点去的去找,所以干脆把收藏功能拿出来用,做个菜单,随时查看和删除。
查询代码: 1.我收藏的版块
[代码]php代码:
  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.我收藏的帖子
[代码]php代码:
  1. $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.我收藏的文章
[代码]php代码:
  1. $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");
复制代码
//日志

  1. $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.我收藏的群组
[代码]php代码:
  1. $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.我收藏的日志
[代码]php代码:
  1. $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条,像帖子、文章、日志这种可能会收藏很多,如果有分页需要可以利用自带的分页函数来分页。

补充调用方法
[代码]php代码:
  1. <font size="4"><b>{loop $forum_favorites $value}</b></font>
  2. <font size="4"><b>$value['字段']</b></font>
  3. <font size="4"><b>{/loop}</b></font>
复制代码


[代码]php代码:
  1. <font size="4"><b>{loop $thread_favorites $value}</b></font>
  2. <font size="4"><b>$value['字段']</b></font>
  3. <font size="4"><b>{/loop}</b></font>
复制代码




欢迎访问[color=Red]站长帮[/color],记住我们的域名[color=Red]www.yunxunwl.com[/color]
您需要登录后才可以回帖 登录 | 注册  

本版积分规则