table_common_admincp_cmenu.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_admincp_cmenu.php 27806 2012-02-15 03:20:46Z svn_project_zhangjie $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_admincp_cmenu extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'common_admincp_cmenu';
  15. $this->_pk = 'id';
  16. parent::__construct();
  17. }
  18. public function count_by_uid($uid) {
  19. return DB::result_first('SELECT COUNT(*) FROM %t WHERE uid=%d AND sort=1', array($this->_table, $uid));
  20. }
  21. public function fetch_all_by_uid($uid, $start = 0, $limit = 0) {
  22. return DB::fetch_all('SELECT * FROM %t WHERE uid=%d AND sort=1 ORDER BY displayorder, dateline DESC, clicks DESC '.DB::limit($start, $limit),
  23. array($this->_table, $uid));
  24. }
  25. public function delete($id, $uid = 0) {
  26. if(empty($id)) {
  27. return false;
  28. }
  29. return DB::query('DELETE FROM %t WHERE '.DB::field('id', $id).' %i', array($this->_table, ($uid ? ' AND '.DB::field('uid', $uid) : '')));
  30. }
  31. public function fetch_id_by_uid_sort_url($uid, $sort, $url) {
  32. return DB::result_first('SELECT id FROM %t WHERE uid=%d AND sort=%d AND url=%s', array($this->_table, $uid, $sort, $url));
  33. }
  34. public function increase_clicks($id) {
  35. return DB::query('UPDATE %t SET clicks=clicks+1 WHERE id=%d', array($this->_table, $id));
  36. }
  37. }
  38. ?>