table_forum_hotreply_number.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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_hotreply_number.php 36278 2016-12-09 07:52:35Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_forum_hotreply_number extends discuz_table {
  12. public function __construct() {
  13. $this->_table = 'forum_hotreply_number';
  14. $this->_pk = 'pid';
  15. parent::__construct();
  16. }
  17. public function fetch_all_by_pids($pids) {
  18. return DB::fetch_all('SELECT * FROM %t WHERE '.DB::field('pid', $pids), array($this->_table), 'pid');
  19. }
  20. public function fetch_all_by_tid_total($tid, $limit = 5) {
  21. return DB::fetch_all('SELECT * FROM %t WHERE tid=%d ORDER BY total DESC LIMIT %d', array($this->_table, $tid, $limit), 'pid');
  22. }
  23. public function fetch_by_pid($pid) {
  24. return DB::fetch_first('SELECT * FROM %t WHERE pid=%d', array($this->_table, $pid));
  25. }
  26. public function update_num($pid, $typeid) {
  27. $typename = $typeid == 1 ? 'support' : 'against';
  28. return DB::query('UPDATE %t SET '.$typename.'='.$typename.'+1, total=total+1 WHERE pid=%d', array($this->_table, $pid));
  29. }
  30. public function delete_by_tid($tid) {
  31. if(empty($tid)) {
  32. return false;
  33. }
  34. return DB::query('DELETE FROM %t WHERE tid IN (%n)', array($this->_table, $tid));
  35. }
  36. public function delete_by_pid($pids) {
  37. if(empty($pids)) {
  38. return false;
  39. }
  40. return DB::query('DELETE FROM %t WHERE '.DB::field('pid', $pids), array($this->_table));
  41. }
  42. }
  43. ?>