table_common_domain.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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_domain.php 27860 2012-02-16 02:32:58Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_domain extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'common_domain';
  15. $this->_pk = '';
  16. parent::__construct();
  17. }
  18. public function update_by_idtype($idtype, $data) {
  19. if($idtype && !empty($data) && is_array($data)) {
  20. return DB::update($this->_table, $data, DB::field('idtype', $idtype));
  21. }
  22. return 0;
  23. }
  24. public function fetch_all_by_idtype($idtype) {
  25. if(!empty($idtype)) {
  26. return DB::fetch_all('SELECT * FROM %t WHERE '.DB::field('idtype', $idtype), array($this->_table));
  27. }
  28. return array();
  29. }
  30. public function fetch_by_domain_domainroot($domain, $droot) {
  31. return DB::fetch_first('SELECT * FROM %t WHERE domain=%s AND domainroot=%s', array($this->_table, $domain, $droot));
  32. }
  33. public function delete_by_id_idtype($id, $idtype) {
  34. $parameter = array($this->_table, $id, $idtype);
  35. $wherearr = array();
  36. $wherearr[] = is_array($id) ? 'id IN(%n)' : 'id=%d';
  37. $wherearr[] = is_array($idtype) ? 'idtype IN(%n)' : 'idtype=%s';
  38. $wheresql = !empty($wherearr) && is_array($wherearr) ? ' WHERE '.implode(' AND ', $wherearr) : '';
  39. return DB::query("DELETE FROM %t $wheresql", $parameter);
  40. }
  41. public function count_by_domain_domainroot($domain, $droot) {
  42. return DB::result_first('SELECT COUNT(*) FROM %t WHERE domain=%s AND domainroot=%s', array($this->_table, $domain, $droot));
  43. }
  44. }
  45. ?>