table_common_credit_rule.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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_common_credit_rule.php 27900 2012-02-16 07:50:00Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_credit_rule extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'common_credit_rule';
  15. $this->_pk = 'rid';
  16. parent::__construct();
  17. }
  18. public function fetch_all_by_rid($rid = 0) {
  19. $parameter = array($this->_table);
  20. $wherearr = array();
  21. if($rid) {
  22. $rid = dintval($rid, true);
  23. $parameter[] = $rid;
  24. $wherearr[] = is_array($rid) ? 'rid IN(%n)' : 'rid=%d';
  25. }
  26. $wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE '.implode(' AND ', $wherearr) : '';
  27. return DB::fetch_all("SELECT * FROM %t $wheresql ORDER BY rid DESC", $parameter, $this->_pk);
  28. }
  29. public function fetch_all_rule() {
  30. return DB::fetch_all('SELECT * FROM %t ORDER BY rid DESC', array($this->_table));
  31. }
  32. public function fetch_all_by_action($action) {
  33. if(!empty($action)) {
  34. return DB::fetch_all('SELECT * FROM %t WHERE action IN(%n)', array($this->_table, $action), $this->_pk);
  35. }
  36. return array();
  37. }
  38. }
  39. ?>