table_home_clickuser.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_clickuser.php 27862 2012-02-16 02:52:07Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_home_clickuser extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'home_clickuser';
  15. $this->_pk = '';
  16. parent::__construct();
  17. }
  18. public function fetch_all_by_id_idtype($id, $idtype, $start = 0, $limit = 0) {
  19. $id = dintval($id, is_array($id) ? true : false);
  20. $parameter = array($this->_table, $id, $idtype);
  21. $wherearr = array();
  22. $wherearr[] = is_array($id) ? 'id IN(%n)' : 'id=%d';
  23. $wherearr[] = 'idtype=%s';
  24. $wheresql = ' WHERE '.implode(' AND ', $wherearr);
  25. return DB::fetch_all("SELECT * FROM %t $wheresql ORDER BY dateline DESC ".DB::limit($start, $limit), $parameter);
  26. }
  27. public function delete_by_id_idtype($id, $idtype) {
  28. $id = dintval($id, is_array($id) ? true : false);
  29. $parameter = array($this->_table, $id, $idtype);
  30. $wherearr = array();
  31. $wherearr[] = is_array($id) ? 'id IN(%n)' : 'id=%d';
  32. $wherearr[] = 'idtype=%s';
  33. $wheresql = ' WHERE '.implode(' AND ', $wherearr);
  34. return DB::query('DELETE FROM %t '.$wheresql, $parameter);
  35. }
  36. public function delete_by_dateline($dateline) {
  37. return DB::query('DELETE FROM %t WHERE dateline<%d', array($this->_table, $dateline));
  38. }
  39. public function delete_by_uid($uids) {
  40. $uids = dintval($uids, is_array($uids) ? true : false);
  41. if($uids) {
  42. return DB::delete($this->_table, DB::field('uid', $uids));
  43. }
  44. return 0;
  45. }
  46. public function count_by_uid_id_idtype($uid, $id, $idtype) {
  47. return DB::result_first('SELECT COUNT(*) FROM %t WHERE uid=%d AND id=%d AND idtype=%s', array($this->_table, $uid, $id, $idtype));
  48. }
  49. public function count_by_id_idtype($id, $idtype) {
  50. return DB::result_first('SELECT COUNT(*) FROM %t WHERE id=%d AND idtype=%s', array($this->_table, $id, $idtype));
  51. }
  52. }
  53. ?>