table_common_block_favorite.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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_block_favorite.php 27846 2012-02-15 09:04:33Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_block_favorite extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'common_block_favorite';
  15. $this->_pk = 'favid';
  16. parent::__construct();
  17. }
  18. public function delete_by_uid_bid($uid, $bid) {
  19. return ($uid = dintval($uid)) && ($bid = dintval($bid)) ? DB::delete($this->_table, DB::field('uid', $uid).' AND '.DB::field('bid', $bid)) : false;
  20. }
  21. public function delete_by_bid($bid) {
  22. return ($bid = dintval($bid)) ? DB::delete($this->_table, DB::field('bid', $bid)) : false;
  23. }
  24. public function count_by_uid_bid($uid, $bid){
  25. return ($uid = dintval($uid)) && ($bid = dintval($bid)) ? DB::result_first('SELECT count(*) FROM %t WHERE uid=%d AND bid=%d', array($this->_table, $uid, $bid)) : false;
  26. }
  27. public function fetch_all_by_uid($uid) {
  28. return ($uid = dintval($uid)) ? DB::fetch_all('SELECT * FROM %t WHERE uid=%d ORDER BY dateline DESC', array($this->_table, $uid), 'bid') : array();
  29. }
  30. }
  31. ?>