去评论
dz插件网

Discuz! X 数据查询表 - 常用查询

admin
2020/07/07 09:09:28
调用最新主题
  1. $new=DB::fetch_all("SELECT tid,subject FROM ".DB::table('forum_thread')." ORDER BY `dateline` desc LIMIT 0,1;");

调用最新主题封面图
  1. $img=DB::fetch_all("SELECT a.subject,a.tid,b.attachment FROM ".DB::table("forum_thread")." a LEFT JOIN ".DB::table("forum_threadimage")." b on b.tid=a.tid WHERE a.`attachment`=2 ORDER BY a.`dateline` DESC LIMIT 0,5");

调用当前登录用户阅读权限
  1. $read=DB::result(DB::query("SELECT b.readaccess FROM ".DB::table('common_member')." a left join ".DB::table('common_usergroup_field')." b on b.groupid=a.groupid WHERE a.`uid`= '$_G[uid]'"));

调用常用统计数据
  1. //获取VERSION、RELEASE$version = unserialize($_G['setting']['cloudaddons_newversion']);//获取站长用户名$name = DB::result_first("select username from ".DB::table("common_member")." where uid = 1");//获取建站时间$time = DB::result_first("select regdate from ".DB::table("common_member")." where uid = 1");//获取模板个数$templates = DB::result_first("select count(styleid) from ".DB::table("common_style")."");//获取插件个数$plugins = DB::result_first("select count(pluginid) from ".DB::table("common_plugin")."");//获取会员人数$users = DB::result_first("select count(uid) from ".DB::table("common_member")."");//获取临时会员人数$guests = DB::result_first("select count(conopenid) from ".DB::table("common_connect_guest")."");//获取会员总人数$all_users = $users + $guests;//获取管理团队人数$admins = DB::result_first("select count(uid) from ".DB::table("common_member")." where groupid in (1,2)");//获取最新注册会员$newuser = DB::result_first("select username from ".DB::table("common_member")." order BY regdate desc");//获取发帖会员人数$post_posts = DB::result_first("select count(uid) from ".DB::table("common_member_count")." where posts > 0 ");//获取发表主题会员人数$post_threads = DB::result_first("select count(uid) from ".DB::table("common_member_count")." where threads > 0 ");//获取版块数$forums = DB::result_first("select count(fid) from ".DB::table("forum_forum")." where type = 'forum' and status in (0,1)");//获取总帖数$posts = DB::result_first("select count(pid) from ".DB::table("forum_post")."");//获取主题数$threads = DB::result_first("select count(tid) from ".DB::table("forum_thread")."");//获取精华主题数$digest = DB::result_first("select count(digest) from ".DB::table("forum_thread")." where digest > 0");//获取高亮主题数$highlight = DB::result_first("select count(highlight) from ".DB::table("forum_thread")." where highlight > 0");//获取置顶主题数$displayorder = DB::result_first("select count(displayorder) from ".DB::table("forum_thread")." where displayorder > 0");//获取附件主题数$attachment = DB::result_first("select count(tid) from ".DB::table("forum_thread")." where attachment > 0");//获取待审核主题数$moderate_threads = DB::result_first("select count(id) from ".DB::table("forum_thread_moderate")." where status = 0");//获取已忽略主题数$moderate_ignore_threads = DB::result_first("select count(id) from ".DB::table("forum_thread_moderate")." where status = 1");//获取待审核回复数$moderate_posts = DB::result_first("select count(id) from ".DB::table("forum_post_moderate")." where status = 0");//获取已忽略回复数$moderate_ignore_posts = DB::result_first("select count(id) from ".DB::table("forum_post_moderate")." where status = 1");//获取主题回收站数$recyclebin_threads = DB::result_first("select count(tid) from ".DB::table("forum_thread")." where displayorder = -1");//获取回复回收站数$recyclebin_posts = DB::result_first("select count(tid) from ".DB::table("forum_post")." where invisible = -5");//获取访问总数$views = DB::result_first("select sum(views) from ".DB::table("forum_thread")."");//获取回复总数$replies = DB::result_first("select sum(replies) from ".DB::table("forum_thread")."");//获取支持总数$recommend_add = DB::result_first("select sum(recommend_add) from ".DB::table("forum_thread")."");//获取反对总数$recommend_sub = DB::result_first("select sum(recommend_sub) from ".DB::table("forum_thread")."");//获取收藏总数$favtimes = DB::result_first("select sum(favtimes) from ".DB::table("forum_thread")."");//获取分享总数$sharetimes = DB::result_first("select sum(sharetimes) from ".DB::table("forum_thread")."");//获取会员:男性$users_man = DB::result_first("select count(uid) from ".DB::table("common_member_profile")." where gender = 1 ");//获取会员:女性$users_woman = DB::result_first("select count(uid) from ".DB::table("common_member_profile")." where gender = 2 ");//获取会员:80后$users_80 = DB::result_first("select count(uid) from ".DB::table("common_member_profile")." where birthyear > 1980 and birthyear < 1989 ");