table_home_blog_category.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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_blog_category.php 27449 2012-02-01 05:32:35Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_home_blog_category extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'home_blog_category';
  15. $this->_pk = 'catid';
  16. parent::__construct();
  17. }
  18. public function fetch_all_by_displayorder() {
  19. return DB::fetch_all("SELECT * FROM %t ORDER BY displayorder", array($this->_table), $this->_pk);
  20. }
  21. public function fetch_all_numkey($numkey) {
  22. $allow_numkey = array('portal', 'articles', 'num');
  23. if(!in_array($numkey, $allow_numkey)) {
  24. return null;
  25. }
  26. return DB::fetch_all("SELECT catid, $numkey FROM %t", array($this->_table), $this->_pk);
  27. }
  28. public function update_num_by_catid($num, $catid, $numplus = true, $numlimit = false) {
  29. $args = array($this->_table, $num, $catid);
  30. if($numlimit !== false) {
  31. $sql = ' AND num>0';
  32. $args[] = $numlimit;
  33. }
  34. return DB::query("UPDATE %t SET num=".(($numplus) ? 'num+' : '')."%d WHERE catid=%d {$sql}", $args);
  35. }
  36. public function fetch_catname_by_catid($catid) {
  37. return DB::result_first("SELECT catname FROM %t WHERE catid=%d", array($this->_table, $catid));
  38. }
  39. }
  40. ?>