table_common_member_crime.php 2.0 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_common_member_crime.php 34074 2013-10-08 01:30:38Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_member_crime extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'common_member_crime';
  15. $this->_pk = 'cid';
  16. parent::__construct();
  17. }
  18. public function fetch_all_by_uid($uid) {
  19. return $uid ? DB::fetch_all('SELECT * FROM %t WHERE uid=%d ORDER BY dateline DESC', array($this->_table, $uid), $this->_pk) : array();
  20. }
  21. public function count_by_uid_action($uid, $action) {
  22. return $uid ? DB::result_first('SELECT COUNT(*) FROM %t WHERE uid=%d AND action=%d', array($this->_table, $uid, $action)) : 0;
  23. }
  24. public function count_by_where($where) {
  25. return $where ? DB::result_first('SELECT COUNT(*) FROM %t %i ', array($this->_table, $where)) : $this->count();
  26. }
  27. public function fetch_all_by_where($where, $start = 0, $limit = 0) {
  28. return DB::fetch_all('SELECT * FROM %t %i ORDER BY dateline DESC '.DB::limit($start, $limit), array($this->_table, $where));
  29. }
  30. public function fetch_all_by_uid_action($uid, $action) {
  31. return DB::fetch_all('SELECT * FROM %t WHERE '.DB::field('uid', $uid).' AND '.DB::field('action', $action).' ORDER BY dateline', array($this->_table));
  32. }
  33. public function fetch_all_by_cid($cid, $action, $limit) {
  34. if(!$cid) {
  35. return DB::fetch_all('SELECT * FROM %t '.($action ? 'WHERE '.DB::field('action', $action) : '').' ORDER BY cid DESC '.DB::limit($limit), array($this->_table), $this->_pk);
  36. } else {
  37. return DB::fetch_all('SELECT * FROM %t WHERE '.DB::field('cid', $cid, '<').($action ? ' AND '.DB::field('action', $action) : '').' ORDER BY cid DESC '.DB::limit($limit), array($this->_table), $this->_pk);
  38. }
  39. }
  40. public function delete_by_uid($uids) {
  41. if(!$uids){
  42. return null;
  43. }
  44. DB::delete($this->_table, DB::field('uid', $uids));
  45. }
  46. }
  47. ?>