table_forum_forumrecommend.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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_forumrecommend.php 27745 2012-02-14 01:43:38Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_forum_forumrecommend extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'forum_forumrecommend';
  15. $this->_pk = 'tid';
  16. parent::__construct();
  17. }
  18. public function delete_by_fid($fids, $moderatorid = false) {
  19. if(!$fids) {
  20. return;
  21. }
  22. $moderatorid = $moderatorid !== false ? ' AND moderatorid='.intval($moderatorid) : '';
  23. DB::query("DELETE FROM %t WHERE %i %i", array($this->_table, DB::field('fid', $fids), $moderatorid));
  24. }
  25. public function delete_by_tid($tids) {
  26. if(!$fids) {
  27. return;
  28. }
  29. return DB::delete($this->_table, DB::field('tid', $tids));
  30. }
  31. public function delete_old() {
  32. DB::query("DELETE FROM %t WHERE expiration>0 AND expiration<%d", array($this->_table, TIMESTAMP), false, true);
  33. }
  34. public function fetch_all_by_fid($fid, $position = false, $moderatorid = false, $start = 0, $limit = 0) {
  35. $position = $position ? ' AND '.DB::field('position', array(0, $position)) : '';
  36. $moderatorid = $moderatorid ? ' AND '.DB::field('moderatorid', array(0, $moderatorid)) : '';
  37. $limit = $start && $limit ? ' LIMIT '.intval($start).', '.intval($limit) : '';
  38. return DB::fetch_all('SELECT * FROM %t WHERE fid=%d %i %i ORDER BY displayorder %i', array($this->_table, $fid, $position, $moderatorid, $limit));
  39. }
  40. public function count_by_fid($fid) {
  41. return DB::result_first("SELECT COUNT(*) FROM %t WHERE fid=%d", array($this->_table, $fid));
  42. }
  43. }
  44. ?>