table_forum_polloption_image.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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_polloption_image.php 31112 2012-07-17 09:16:21Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_forum_polloption_image extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'forum_polloption_image';
  15. $this->_pk = 'aid';
  16. parent::__construct();
  17. }
  18. public function fetch_all_by_tid($tids) {
  19. return DB::fetch_all('SELECT * FROM %t WHERE tid'.(is_array($tids) ? ' IN(%n)' : '=%d'), array($this->_table, $tids), 'poid');
  20. }
  21. public function count_by_aid_uid($aid, $uid) {
  22. return DB::result_first('SELECT COUNT(*) FROM %t WHERE aid=%d AND uid=%d', array($this->_table, $aid, $uid));
  23. }
  24. public function delete_by_tid($tids) {
  25. return DB::delete($this->_table, DB::field('tid', $tids));
  26. }
  27. public function clear() {
  28. require_once libfile('function/forum');
  29. $deltids = array();
  30. $query = DB::query("SELECT tid, attachment, thumb FROM %t WHERE tid=0 AND dateline<=%d", array($this->_table, TIMESTAMP - 86400));
  31. while($attach = DB::fetch($query)) {
  32. dunlink($attach);
  33. $deltids[] = $attach['tid'];
  34. }
  35. if($deltids) {
  36. $this->delete_by_tid($deltids);
  37. }
  38. }
  39. }
  40. ?>