table_forum_medal.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_medal.php 27745 2012-02-14 01:43:38Z monkey $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_forum_medal extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'forum_medal';
  15. $this->_pk = 'medalid';
  16. parent::__construct();
  17. }
  18. public function fetch_all_data($available = false) {
  19. $available = $available !== false ? ' WHERE available='.intval($available) : '';
  20. return DB::fetch_all('SELECT * FROM %t %i ORDER BY displayorder', array($this->_table, $available));
  21. }
  22. public function fetch_all_name_by_available($available = 1) {
  23. $data = array();
  24. foreach($this->fetch_all_data($available) as $value) {
  25. $data[$value['medalid']] = array('medalid' => $value['medalid'], 'name' => $value['name']);
  26. }
  27. return $data;
  28. }
  29. public function count_by_available() {
  30. return DB::result_first('SELECT COUNT(*) FROM %t WHERE available=1', array($this->_table));
  31. }
  32. public function fetch_all_by_id($id) {
  33. if(!$id) {
  34. return;
  35. }
  36. return DB::fetch_all("SELECT * FROM %t WHERE %i ORDER BY displayorder", array($this->_table, DB::field('medalid', $id)));
  37. }
  38. }
  39. ?>