table_forum_tradecomment.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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_tradecomment.php 27737 2012-02-13 09:46:21Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_forum_tradecomment extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'forum_tradecomment';
  15. $this->_pk = 'id';
  16. parent::__construct();
  17. }
  18. function fetch_all_by_rateeid($rateeid, $type, $dateline = 0) {
  19. $dateline = $dateline ? 'AND dateline>='.intval($dateline) : '';
  20. return DB::fetch_all("SELECT * FROM %t WHERE rateeid=%d AND type=%d %i", array($this->_table, $rateeid, $type, $dateline));
  21. }
  22. function fetch_all_list($from, $uid, $dateline, $score, $start) {
  23. $sql = $from == 'myself' ? "tc.raterid='".intval($uid)."'" : "tc.rateeid='".intval($uid)."'";
  24. $sql .= $from == 'buyer' ? ' AND tc.type=0' : ($from == 'seller' ? ' AND tc.type=1' : '');
  25. $dateline = $dateline !== false ? ' AND tc.dateline>='.intval($dateline) : '';
  26. $score = $score !== false ? ' AND tc.score='.intval($score) : '';
  27. return DB::fetch_all("SELECT tc.*, tl.subject, tl.price, tl.credit FROM %t tc LEFT JOIN %t tl USING(orderid) WHERE %i %i %i ORDER BY tc.dateline DESC LIMIT %d, 10",
  28. array($this->_table, 'forum_tradelog', $sql, $dateline, $score, $start));
  29. }
  30. function count_list($from, $uid, $dateline, $score) {
  31. $sql = $from == 'myself' ? "tc.raterid='".intval($uid)."'" : "tc.rateeid='".intval($uid)."'";
  32. $sql .= $from == 'buyer' ? ' AND tc.type=0' : ($from == 'seller' ? ' AND tc.type=1' : '');
  33. $dateline = $dateline !== false ? ' AND tc.dateline>='.intval($dateline) : '';
  34. $score = $score !== false ? ' AND tc.score='.intval($score) : '';
  35. return DB::result_first("SELECT COUNT(*) FROM %t tc WHERE %i %i %i", array($this->_table, $sql, $dateline, $score));
  36. }
  37. function get_month_score($uid, $type, $rateeid) {
  38. $monthfirstday = mktime(0, 0, 0, date('m', TIMESTAMP), 1, date('Y', TIMESTAMP));
  39. return DB::result_first("SELECT COUNT(score) FROM %t WHERE raterid=%d AND type=%d AND dateline>=%d AND rateeid=%d", array($this->_table, $uid, $type, $monthfirstday, $rateeid));
  40. }
  41. }
  42. ?>