table_forum_modwork.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_modwork.php 27800 2012-02-15 02:13:57Z svn_project_zhangjie $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_forum_modwork extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'forum_modwork';
  15. $this->_pk = '';
  16. parent::__construct();
  17. }
  18. public function increase_count_posts_by_uid_modaction_dateline($count, $posts, $uid, $modaction, $dateline) {
  19. return DB::query('UPDATE %t SET count=count+\'%d\', posts=posts+\'%d\' WHERE uid=%d AND modaction=%s AND dateline=%s',
  20. array($this->_table, $count, $posts, $uid, $modaction, $dateline));
  21. }
  22. public function fetch_all_user_count_by_dateline($dateline) {
  23. return DB::fetch_all('SELECT uid, SUM(count) AS actioncount FROM %t WHERE dateline>=%s GROUP BY uid', array($this->_table, $dateline));
  24. }
  25. public function fetch_all_by_uid_dateline($uid, $starttime, $endtime) {
  26. return DB::fetch_all('SELECT * FROM %t WHERE uid=%d AND dateline>=%s AND dateline<%s', array($this->_table, $uid, $starttime, $endtime));
  27. }
  28. public function fetch_all_user_count_posts_by_uid_dateline($uids, $starttime, $endtime) {
  29. if(empty($uids)) {
  30. return array();
  31. }
  32. return DB::fetch_all('SELECT uid, modaction, SUM(count) AS count, SUM(posts) AS posts
  33. FROM %t
  34. WHERE '.DB::field('uid', $uids).' AND dateline>=%s AND dateline<%s GROUP BY uid, modaction',
  35. array($this->_table, $starttime, $endtime));
  36. }
  37. public function delete_by_dateline($dateline) {
  38. return DB::query('DELETE FROM %t WHERE dateline<%s', array($this->_table, $dateline));
  39. }
  40. }
  41. ?>