table_forum_debatepost.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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_debatepost.php 32145 2012-11-15 09:38:42Z liulanbo $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_forum_debatepost extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'forum_debatepost';
  15. $this->_pk = 'pid';
  16. parent::__construct();
  17. }
  18. public function update_voters($pid, $uid) {
  19. DB::query("UPDATE %t SET voters=voters+1, voterids=CONCAT(voterids, '%d\t') WHERE pid=%d", array($this->_table, $uid, $pid));
  20. }
  21. public function fetch_all_voters($tid, $number) {
  22. return DB::fetch_all("SELECT SUM(voters) as voters, stand, uid FROM %t WHERE tid=%d AND stand>'0' GROUP BY uid ORDER BY voters DESC LIMIT %d", array($this->_table, $tid, $number));
  23. }
  24. public function get_stand_by_bestuid($tid, $bestuid, $excludeuids) {
  25. if(!$excludeuids) {
  26. return;
  27. }
  28. return DB::result_first("SELECT stand FROM %t WHERE tid=%d AND uid=%d AND stand>'0' AND %i LIMIT 1", array($this->_table, $tid, $bestuid, DB::field('uid', $excludeuids,'notin')));
  29. }
  30. public function get_numbers_by_bestuid($tid, $bestuid) {
  31. $return = DB::fetch_first("SELECT SUM(voters) AS voters, COUNT(*) AS replies FROM %t WHERE tid=%d AND uid=%d", array($this->_table, $tid, $bestuid));
  32. return array($return['voters'], $return['replies']);
  33. }
  34. public function count_by_tid_stand($tid, $stand) {
  35. return DB::result_first("SELECT COUNT(*) FROM %t WHERE tid=%d AND stand=%d", array($this->_table, $tid, $stand));
  36. }
  37. public function get_firststand($tid, $uid) {
  38. return DB::result_first("SELECT stand FROM %t WHERE tid=%d AND uid=%d AND stand>'0' ORDER BY dateline LIMIT 1", array($this->_table, $tid, $uid));
  39. }
  40. public function delete_by_tid($tids) {
  41. if(!$tids) {
  42. return;
  43. }
  44. return DB::delete($this->_table, DB::field('tid', $tids));
  45. }
  46. }
  47. ?>