table_baidusubmit_urlstat.php 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. if(!defined('IN_DISCUZ')) {
  3. exit('Access Denied');
  4. }
  5. class table_baidusubmit_urlstat extends discuz_table
  6. {
  7. public function __construct()
  8. {
  9. $this->_table = 'baidusubmit_urlstat';
  10. parent::__construct();
  11. }
  12. public function update($time, $num)
  13. {
  14. if (DB::fetch_first('SELECT 1 FROM %t WHERE ctime=%d LIMIT 1', array($this->_table, $time))) {
  15. return DB::query('UPDATE %t SET urlnum=urlnum+%d, urlcount=urlcount+%d WHERE ctime=%d', array($this->_table, $num, $num, $time));
  16. }
  17. $precount = DB::result_first('SELECT urlcount FROM %t ORDER BY ctime DESC LIMIT 1', array($this->_table));
  18. return DB::query('INSERT INTO %t(ctime, urlnum, urlcount) values(%d, %d, %d)', array($this->_table, $time, $num, $precount+$num));
  19. }
  20. public function delete($time)
  21. {
  22. return DB::query('DELETE FROM %t WHERE ctime<%d', array($this->_table, $time));
  23. }
  24. public function getall()
  25. {
  26. return DB::fetch_all('SELECT * FROM %t ORDER BY ctime DESC', array($this->_table));
  27. }
  28. }