table_forum_activityapply.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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_forum_activityapply.php 28709 2012-03-08 08:53:48Z liulanbo $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_forum_activityapply extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'forum_activityapply';
  15. $this->_pk = 'applyid';
  16. parent::__construct();
  17. }
  18. public function fetch_info_for_user($uid, $tid) {
  19. return DB::fetch_first("SELECT * FROM %t WHERE tid=%d AND uid=%d", array($this->_table, $tid, $uid));
  20. }
  21. public function delete_for_user($uid, $tid) {
  22. DB::query("DELETE FROM %t WHERE tid=%d AND uid=%d", array($this->_table, $tid, $uid));
  23. }
  24. public function delete_by_tid($tids) {
  25. return DB::delete($this->_table, DB::field('tid', $tids));
  26. }
  27. public function delete_for_thread($tid, $applyids = array()) {
  28. if($applyids) {
  29. $pksql = " AND ".DB::field('applyid', $applyids);
  30. }
  31. DB::query("DELETE FROM %t WHERE tid=%d $pksql", array($this->_table, $tid));
  32. }
  33. public function fetch_count_for_thread($tid) {
  34. return DB::result_first("SELECT COUNT(*) FROM %t WHERE tid=%d AND verified='1'", array($this->_table, $tid));
  35. }
  36. public function fetch_all_for_thread($tid, $start = 0, $limit = 100, $uid = 0, $master = 0) {
  37. $verifiedsql = empty($master) ? ' AND verified=1' : '';
  38. if(intval($uid)) {
  39. $verifiedsql .= ' AND uid='.intval($uid);
  40. }
  41. return DB::fetch_all("SELECT * FROM %t WHERE tid=%d $verifiedsql ORDER BY dateline DESC".DB::limit($start, $limit), array($this->_table, $tid));
  42. }
  43. public function update_verified_for_thread($verified, $tid, $applyid) {
  44. DB::query("UPDATE %t SET verified=%d WHERE tid=%d AND applyid IN (%n)", array($this->_table, $verified, $tid, $applyid));
  45. }
  46. }
  47. ?>