table_forum_statlog.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: table_forum_statlog.php 31920 2012-10-24 09:18:33Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_forum_statlog extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'forum_statlog';
  15. $this->_pk = 'logdate';
  16. parent::__construct();
  17. }
  18. public function fetch_all_by_logdate($start, $end, $fid) {
  19. return DB::fetch_all('SELECT * FROM %t WHERE logdate>=%s AND logdate<=%s AND type=1 AND fid=%d ORDER BY logdate ASC', array($this->_table, $start, $end, $fid));
  20. }
  21. public function fetch_all_rank_by_logdate($date) {
  22. return DB::fetch_all('SELECT * FROM %t WHERE logdate=%s AND type=1 ORDER BY value DESC', array($this->_table, $date));
  23. }
  24. public function fetch_all_by_fid_type($fid, $type=1) {
  25. return DB::fetch_all("SELECT * FROM %t WHERE fid=%d AND type=%d", array($this->_table, $fid, $type));
  26. }
  27. public function fetch_min_logdate_by_fid($fid) {
  28. return DB::result_first("SELECT MIN(logdate) FROM %t WHERE fid=%d", array($this->_table, $fid));
  29. }
  30. public function insert_stat_log($date) {
  31. return DB::query("REPLACE INTO %t (logdate, fid, `type`, `value`) SELECT %s, fid, 1, todayposts FROM %t WHERE `type` IN ('forum', 'sub') AND `status`<>'3'", array($this->_table, $date, 'forum_forum'));
  32. }
  33. }
  34. ?>