table_common_onlinetime.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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_onlinetime.php 27449 2012-02-01 05:32:35Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_onlinetime extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'common_onlinetime';
  15. $this->_pk = 'uid';
  16. parent::__construct();
  17. }
  18. public function update_onlinetime($uid, $total, $thismonth, $lastupdate) {
  19. if(($uid = intval($uid))) {
  20. DB::query("UPDATE ".DB::table('common_onlinetime')."
  21. SET total=total+'$total', thismonth=thismonth+'$thismonth', lastupdate='".$lastupdate."' WHERE ".DB::field($this->_pk, $uid));
  22. return DB::affected_rows();
  23. }
  24. return false;
  25. }
  26. public function range_by_field($start = 0, $limit = 0, $orderby = '', $sort = '') {
  27. $orderby = in_array($orderby, array('thismonth', 'total', 'lastupdate'), true) ? $orderby : '';
  28. return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).($orderby ? ' WHERE '.$orderby.' >0 ORDER BY '.DB::order($orderby, $sort) : '').' '.DB::limit($start, $limit), null, $this->_pk);
  29. }
  30. public function update_thismonth() {
  31. return DB::update($this->_table, array('thismonth'=>0));
  32. }
  33. }
  34. ?>