table_common_grouppm.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_grouppm.php 27876 2012-02-16 04:28:02Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_grouppm extends discuz_table
  12. {
  13. private $_uids = array();
  14. public function __construct() {
  15. $this->_table = 'common_grouppm';
  16. $this->_pk = 'id';
  17. parent::__construct();
  18. }
  19. public function fetch_all_by_id_authorid($id = 0, $authorid = 0) {
  20. $wherearr = $data = array();
  21. $parameter = array($this->_table);
  22. if($id) {
  23. $id = is_array($id) ? array_map('intval', (array)$id) : dintval($id);
  24. $wherearr[] = is_array($id) ? 'id IN(%n)' : 'id=%d';
  25. $parameter[] = $id;
  26. }
  27. if($authorid) {
  28. $authorid = dintval($authorid);
  29. $wherearr[] = 'authorid=%d';
  30. $parameter[] = $authorid;
  31. }
  32. $wheresql = !empty($wherearr) ? ' WHERE '.implode(' AND ', $wherearr) : '';
  33. $query = DB::query("SELECT * FROM %t $wheresql ORDER BY id DESC", $parameter);
  34. while($row = DB::fetch($query)) {
  35. $data[$row['id']] = $row;
  36. $this->_uids[$row['authorid']] = $row['authorid'];
  37. }
  38. return $data;
  39. }
  40. public function count_by_id_authorid($id, $authorid) {
  41. return DB::result_first('SELECT COUNT(*) FROM %t WHERE id=%d AND authorid=%d', array($this->_table, $id, $authorid));
  42. }
  43. public function get_uids() {
  44. return $this->_uids;
  45. }
  46. }
  47. ?>