table_portal_article_count.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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_portal_article_count.php 29078 2012-03-26 06:55:04Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_portal_article_count extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'portal_article_count';
  15. $this->_pk = 'aid';
  16. parent::__construct();
  17. }
  18. public function increase($ids, $data) {
  19. $ids = array_map('intval', (array)$ids);
  20. $sql = array();
  21. $allowkey = array('commentnum', 'viewnum', 'favtimes', 'sharetimes');
  22. foreach($data as $key => $value) {
  23. if(($value = intval($value)) && in_array($key, $allowkey)) {
  24. $sql[] = "`$key`=`$key`+'$value'";
  25. }
  26. }
  27. if(!empty($sql)){
  28. DB::query("UPDATE ".DB::table($this->_table)." SET ".implode(',', $sql)." WHERE aid IN (".dimplode($ids).")", 'UNBUFFERED');
  29. }
  30. }
  31. public function fetch_all_hotarticle($wheresql, $dateline) {
  32. if(!empty($wheresql) && ($wheresql = (string)$wheresql) && $dateline = dintval($dateline)) {
  33. return DB::fetch_all("SELECT at.* FROM ".DB::table($this->_table)." ac, ".DB::table('portal_article_title')." at WHERE $wheresql AND at.dateline>'$dateline' AND ac.aid=at.aid ORDER BY ac.viewnum DESC LIMIT 10");
  34. } else {
  35. return array();
  36. }
  37. }
  38. }
  39. ?>