table_common_report.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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_common_report.php 27449 2012-02-01 05:32:35Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_report extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'common_report';
  15. $this->_pk = 'id';
  16. parent::__construct();
  17. }
  18. public function fetch_count($operated = 0, $id = 0, $fid = 0) {
  19. $where = empty($operated) ? 'opuid=0' : 'opuid>0';
  20. $idsql = $id ? DB::field('id', $id).' AND ' : '';
  21. $fidsql = $fid ? ' AND '.DB::field('fid', $fid) : '';
  22. return DB::result_first('SELECT count(*) FROM '.DB::table('common_report').' WHERE '.$idsql.$where.$fidsql);
  23. }
  24. public function fetch_all($start = 0, $limit = 100, $operated = 0, $fid = 0) {
  25. $where = empty($operated) ? 'opuid=0' : 'opuid>0';
  26. $order = empty($operated) ? 'num' : 'optime';
  27. $fidsql = $fid ? ' AND '.DB::field('fid', $fid) : '';
  28. return DB::fetch_all("SELECT * FROM %t WHERE $where.$fidsql ORDER BY $order DESC, dateline DESC LIMIT %d, %d", array($this->_table, $start, $limit));
  29. }
  30. public function fetch_by_urlkey($urlkey) {
  31. return DB::result_first("SELECT id FROM %t WHERE urlkey=%s AND opuid='0'", array($this->_table, $urlkey));
  32. }
  33. public function update_num($id, $message) {
  34. DB::query("UPDATE %t SET message=CONCAT_WS('<br>', message, %s), num=num+1 WHERE id=%d", array($this->_table, $message, $id));
  35. }
  36. }
  37. ?>