table_common_myinvite.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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_myinvite.php 28246 2012-02-26 10:03:35Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_myinvite extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'common_myinvite';
  15. $this->_pk = 'id';
  16. parent::__construct();
  17. }
  18. public function fetch_all_by_touid($touid) {
  19. return DB::fetch_all('SELECT * FROM %t WHERE touid=%d ORDER BY dateline DESC', array($this->_table, $touid));
  20. }
  21. public function count_by_touid($touid) {
  22. return DB::result_first('SELECT COUNT(*) FROM %t WHERE touid=%d', array($this->_table, $touid));
  23. }
  24. public function count_by_hash_touid($hash, $touid) {
  25. return DB::result_first('SELECT COUNT(*) FROM %t WHERE hash=%s AND touid=%d', array($this->_table, $hash, $touid));
  26. }
  27. public function delete_by_appid($appid) {
  28. $appid = dintval($appid, true);
  29. if($appid) {
  30. return DB::delete($this->_table, DB::field('appid', $appid));
  31. }
  32. return 0;
  33. }
  34. public function delete_by_touid_or_fromuid($uids) {
  35. $uids = dintval($uids, true);
  36. if($uids) {
  37. return DB::delete($this->_table, DB::field('touid', $uids).' OR '.DB::field('fromuid', $uids));
  38. }
  39. return 0;
  40. }
  41. public function delete_by_hash_touid($hash, $touid) {
  42. $touid = dintval($touid, true);
  43. if(!empty($hash) && $touid) {
  44. return DB::delete($this->_table, DB::field('hash', $hash).' AND '.DB::field('touid', $touid));
  45. }
  46. return 0;
  47. }
  48. public function delete_by_appid_touid($appid, $touid) {
  49. $touid = dintval($touid, true);
  50. $appid = dintval($appid, true);
  51. if($touid && $appid) {
  52. return DB::delete($this->_table, DB::field('appid', $appid).' AND '.DB::field('touid', $touid));
  53. }
  54. return 0;
  55. }
  56. }
  57. ?>