table_home_specialuser.php 1.5 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_home_specialuser.php 28772 2012-03-12 09:21:59Z chenmengshu $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_home_specialuser extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'home_specialuser';
  15. $this->_pk = '';
  16. parent::__construct();
  17. }
  18. public function fetch_all_by_status($status, $start = 0, $limit = 0) {
  19. return DB::fetch_all('SELECT * FROM %t WHERE status=%d ORDER BY displayorder'.DB::limit($start, $limit), array($this->_table, $status), 'uid');
  20. }
  21. public function count_by_status($status, $username = '') {
  22. $addsql = $username ? " AND username='".addslashes($username)."' " : '';
  23. return DB::result_first('SELECT COUNT(*) FROM %t WHERE status=%d'.$addsql, array($this->_table, $status));
  24. }
  25. public function update_by_uid_status($uid, $status, $data) {
  26. if(!empty($data) && is_array($data) && ($uid = dintval($uid))) {
  27. return DB::update($this->_table, $data, array('uid' => $uid, 'status' => dintval($status)));
  28. }
  29. return 0;
  30. }
  31. public function delete_by_uid_status($uid, $status) {
  32. return ($uid = dintval($uid, true)) ? DB::delete($this->_table, DB::field('uid', $uid).' AND '.DB::field('status', dintval($status))) : false;
  33. }
  34. public function fetch_by_uid_status($uid, $status) {
  35. return ($uid = dintval($uid, true)) ? DB::fetch_first('SELECT * FROM %t WHERE uid=%d AND status=%d', array($this->_table, $uid, $status)) : array();
  36. }
  37. }
  38. ?>