table_common_district.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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_district.php 28647 2012-03-07 02:03:00Z chenmengshu $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_district extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'common_district';
  15. $this->_pk = 'id';
  16. parent::__construct();
  17. }
  18. public function fetch_all_by_upid($upid, $order = null, $sort = 'DESC') {
  19. $upid = is_array($upid) ? array_map('intval', (array)$upid) : dintval($upid);
  20. if($upid !== null) {
  21. $ordersql = $order !== null && !empty($order) ? ' ORDER BY '.DB::order($order, $sort) : '';
  22. return DB::fetch_all('SELECT * FROM %t WHERE '.DB::field('upid', $upid)." $ordersql", array($this->_table), $this->_pk);
  23. }
  24. return array();
  25. }
  26. public function fetch_all_by_name($name) {
  27. if(!empty($name)) {
  28. return DB::fetch_all('SELECT * FROM %t WHERE '.DB::field('name', $name), array($this->_table));
  29. }
  30. return array();
  31. }
  32. }
  33. ?>