table_forum_threadcalendar.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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_threadcalendar.php 31913 2012-10-24 06:52:26Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_forum_threadcalendar extends discuz_table {
  12. public function __construct() {
  13. $this->_table = 'forum_threadcalendar';
  14. $this->_pk = 'cid';
  15. parent::__construct();
  16. }
  17. public function fetch_by_fid_dateline($fid, $dateline = 0, $order = 'dateline', $sort = 'DESC') {
  18. $parameter = array($this->_table);
  19. $wherearr = array();
  20. $wheresql = '';
  21. if($fid) {
  22. $wherearr[] = 'fid=%d';
  23. $parameter[] = $fid;
  24. }
  25. if($dateline) {
  26. $wherearr[] = 'dateline=%d';
  27. $parameter[] = $dateline;
  28. }
  29. if($wherearr) {
  30. $wheresql = ' WHERE '.implode(' AND ', $wherearr);
  31. }
  32. return DB::fetch_first('SELECT * FROM %t '.$wheresql.' ORDER BY '.DB::order($order, $sort), $parameter, $this->_pk);
  33. }
  34. public function fetch_all_by_dateline($dateline) {
  35. $dateline = dintval($dateline);
  36. if($dateline) {
  37. return DB::fetch_all('SELECT * FROM %t WHERE dateline=%d', array($this->_table, $dateline), 'fid');
  38. } else {
  39. return array();
  40. }
  41. }
  42. public function fetch_all_by_fid_dateline($fids, $dateline = 0) {
  43. $parameter = array($this->_table);
  44. $wherearr = array();
  45. $wheresql = '';
  46. $fids = dintval($fids, true);
  47. if($fids) {
  48. $wherearr[] = is_array($fids) ? 'fid IN(%n)' : 'fid=%d';
  49. $parameter[] = $fids;
  50. }
  51. $dateline = dintval($dateline);
  52. if($dateline) {
  53. $wherearr[] = 'dateline=%d';
  54. $parameter[] = $dateline;
  55. }
  56. if($wherearr) {
  57. $wheresql = ' WHERE '.implode(' AND ', $wherearr);
  58. }
  59. return DB::fetch_all('SELECT * FROM %t '.$wheresql, $parameter, 'fid');
  60. }
  61. public function insert_multiterm($dataarr) {
  62. $allkey = array('fid', 'dateline', 'hotnum');
  63. $sql = array();
  64. foreach($dataarr as $key => $value) {
  65. if(is_array($value)) {
  66. $fid = dintval($value['fid']);
  67. $dateline = dintval($value['dateline']);
  68. $hotnum = dintval($value['hotnum']);
  69. $sql[] = "($fid, $dateline, $hotnum)";
  70. }
  71. }
  72. if($sql) {
  73. return DB::query('INSERT INTO '.DB::table($this->_table)." (`fid`, `dateline`, `hotnum`) VALUES ".implode(',', $sql), true);
  74. }
  75. return false;
  76. }
  77. }
  78. ?>