XaInk - 教程
type: channel
link: http://www.xa.ink/category/tutorial/
items: Typecho常用统计相关的代码

Typecho常用统计相关的代码
type: item
date: 2024-04-19T22:58:00+08:00
description: 全部统计代码<?php Typecho_Widget::widget('Widget_Stat')->to($stat); ?>说明代码获取已发布的文章数目$stat->publishedPostsNum();获取待审核的文章数目$stat->waitingPostsNum();获取草稿文章数目$stat->draftPostsNum();获取当前用户已发布的文章数目$stat->myPublishedPostsNum();获取当前用户待审核文章数目$stat->myWaitingPostsNum();获取当前用户草稿文章数目$stat->myDraftPostsNum();获取当前用户已发布的文章数目$stat->currentPublishedPostsNum();获取当前用户待审核文章数目$stat->currentWaitingPostsNum();获取当前用户草稿文章数目$stat->currentDraftPostsNum();获取已发布页面数目$stat->publishedPagesNum();获取草稿页面数目$stat->draftPagesNum();获取当前显示的评论数目$stat->publishedCommentsNum();获取当前待审核的评论数目$stat->waitingCommentsNum();获取当前垃圾评论数目$stat->spamCommentsNum();获取当前用户显示的评论数目$stat->myPublishedCommentsNum();获取当前用户显示的评论数目$stat->myWaitingCommentsNum();获取当前用户显示的评论数目$stat->mySpamCommentsNum();获取当前文章的评论数目$stat->currentCommentsNum();获取当前文章已审核的评论数目$stat->currentPublishedCommentsNum();获取当前文章未审核的评论数目$stat->currentWaitingCommentsNum();获取分类数目$stat->categoriesNum();统计搜索关键字后的文章数function xaGetSearchTotal($keywords) { $db = Typecho_Db::get(); $query = $db->select('COUNT(*) as qty')->from('table.contents') ->where('title LIKE ? OR text LIKE ?', '%' . $keywords . '%', '%' . $keywords . '%') ->where("table.contents.password IS NULL OR table.contents.password = ''") ->where('type = ? and status = ?', 'post', 'publish'); $count = $db->fetchRow($query); return $count['qty']; }