table_common_member_forum_buylog.php 1.4 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_common_member_security.php 27449 2012-02-01 05:32:35Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_member_forum_buylog extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'common_member_forum_buylog';
  15. $this->_pk = 'uid';
  16. $this->_pre_cache_key = 'common_member';
  17. $this->_allowmem = memory('check');
  18. $this->_cache_ttl = 86400;
  19. parent::__construct();
  20. }
  21. public function get_credits($uid, $fid) {
  22. $credits = $this->fetch_cache($uid.'_'.$fid, 'common_member_forum_buylog_');
  23. if(!$credits) {
  24. $credits = DB::result_first('SELECT credits FROM %t WHERE uid=%d AND fid=%d', array($this->_table, $uid, $fid));
  25. $this->store_cache($uid.'_'.$fid, $credits, $this->_cache_ttl, 'common_member_forum_buylog_');
  26. return $credits;
  27. } else {
  28. return $credits;
  29. }
  30. }
  31. public function update_credits($uid, $fid, $credits) {
  32. C::t('common_member_forum_buylog')->insert(array('uid' => $uid, 'fid' => $fid, 'credits' => $credits), false, true);
  33. $this->store_cache($uid.'_'.$fid, $credits, $this->_cache_ttl, 'common_member_forum_buylog_');
  34. }
  35. public function delete_by_uid($uids) {
  36. DB::delete($this->_table, DB::field('uid', $uids));
  37. }
  38. public function delete_by_fid($fids) {
  39. DB::delete($this->_table, DB::field('fid', $fids));
  40. }
  41. }
  42. ?>