table_common_card.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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_card.php 27846 2012-02-15 09:04:33Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_card extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'common_card';
  15. $this->_pk = 'id';
  16. parent::__construct();
  17. }
  18. public function update_by_typeid($typeid, $data) {
  19. if(($typeid = dintval($typeid, true)) && !empty($data) && is_array($data)) {
  20. return DB::update($this->_table, $data, DB::field('typeid', $typeid));
  21. }
  22. return false;
  23. }
  24. public function count_by_where($where) {
  25. return ($where = (string)$where) ? DB::result_first('SELECT COUNT(*) FROM '.DB::table('common_card').' WHERE '.$where) : 0;
  26. }
  27. public function fetch_all_by_where($where, $start = 0, $limit = 0) {
  28. $where = $where ? ' WHERE '.(string)$where : '';
  29. return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).$where.' ORDER BY dateline DESC'.DB::limit($start, $limit));
  30. }
  31. public function update_to_overdue($timestamp) {
  32. return ($timestamp = dintval($timestamp)) ? DB::query('UPDATE '.DB::table('common_card')." SET status = 9 WHERE status = '1' AND cleardateline <= '$timestamp'") : false;
  33. }
  34. }
  35. ?>