table_home_blacklist.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_home_blacklist.php 30819 2012-06-21 07:51:49Z chenmengshu $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_home_blacklist extends discuz_table
  12. {
  13. private $_buids = array();
  14. public function __construct() {
  15. $this->_table = 'home_blacklist';
  16. $this->_pk = '';
  17. parent::__construct();
  18. }
  19. public function count_by_uid_buid($uid, $buid = 0) {
  20. $parameter = array($this->_table);
  21. $wherearr = array();
  22. if($uid) {
  23. $parameter[] = $uid;
  24. $wherearr[] = 'uid=%d';
  25. }
  26. if($buid) {
  27. $parameter[] = $buid;
  28. $wherearr[] = "buid=%d";
  29. }
  30. $wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE '.implode(' AND ', $wherearr) : '';
  31. return DB::result_first("SELECT COUNT(*) FROM %t $wheresql", $parameter);
  32. }
  33. public function fetch_all_by_uid($uid, $start = 0, $limit = 0) {
  34. $data = array();
  35. $query = DB::query('SELECT * FROM %t WHERE uid=%d ORDER BY dateline DESC '.DB::limit($start, $limit), array($this->_table, $uid));
  36. while($value = DB::fetch($query)) {
  37. $data[$value['buid']] = $value;
  38. }
  39. return $data;
  40. }
  41. public function fetch_all_by_uid_buid($uid, $buids) {
  42. return DB::fetch_all('SELECT * FROM %t WHERE uid=%d AND buid IN(%n)', array($this->_table, $uid, $buids), 'buid');
  43. }
  44. public function delete_by_uid_buid($uid, $buid) {
  45. return DB::query('DELETE FROM %t WHERE uid=%d AND buid=%d', array($this->_table, $uid, $buid));
  46. }
  47. }
  48. ?>