table_home_feed_app.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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_feed_app.php 27903 2012-02-16 08:06:10Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_home_feed_app extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'home_feed_app';
  15. $this->_pk = 'feedid';
  16. parent::__construct();
  17. }
  18. public function fetch_all_by_uid_icon($uids = null, $icon = '', $start = 0, $limit = 0) {
  19. $parameter = array($this->_table);
  20. $wherearr = array();
  21. if($uids !== null) {
  22. $uids = dintval($uids, true);
  23. $wherearr[] = is_array($uids) ? 'uid IN(%n)' : 'uid=%d';
  24. $parameter[] = $uids;
  25. }
  26. if(!empty($icon)) {
  27. $wherearr[] = 'icon=%s';
  28. $parameter[] = $icon;
  29. }
  30. $wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE '.implode(' AND ', $wherearr) : '';
  31. return DB::fetch_all("SELECT * FROM %t $wheresql ORDER BY dateline DESC ".DB::limit($start, $limit), $parameter, $this->_pk);
  32. }
  33. public function optimize_table() {
  34. return DB::query("OPTIMIZE TABLE %t", array($this->_table), true);
  35. }
  36. public function delete_by_dateline($dateline) {
  37. $dateline = dintval($dateline);
  38. if($dateline) {
  39. return DB::delete($this->_table, DB::field('dateline', $dateline, '<'));
  40. }
  41. return 0;
  42. }
  43. }
  44. ?>