ExtraGroup.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. namespace We7\Table\Users;
  7. class ExtraGroup extends \We7Table {
  8. protected $tableName = 'users_extra_group';
  9. protected $primaryKey = 'id';
  10. protected $field = array(
  11. 'uid',
  12. 'uni_group_id',
  13. 'create_group_id',
  14. );
  15. protected $default = array(
  16. 'uid' => '',
  17. 'uni_group_id' => '0',
  18. 'create_group_id' => '0',
  19. );
  20. public function searchWithUidCreateGroupId($uid, $create_group_id) {
  21. return $this->where('uid', $uid)->where('create_group_id', $create_group_id);
  22. }
  23. public function getUniGroupByUidAndGroupid($uid, $uni_group_id) {
  24. $where = array('uid' => $uid, 'uni_group_id' => $uni_group_id);
  25. return $this->where($where)->get();
  26. }
  27. public function addExtraUniGroup($uid, $uni_group_id) {
  28. $data = array('uid' => $uid, 'uni_group_id' => $uni_group_id);
  29. return $this->fill($data)->save();
  30. }
  31. public function getCreateGroupByUidAndGroupid($uid, $create_group_id) {
  32. $where = array('uid' => $uid, 'create_group_id' => $create_group_id);
  33. return $this->where($where)->get();
  34. }
  35. public function addExtraCreateGroup($uid, $create_group_id) {
  36. $data = array('uid' => $uid, 'create_group_id' => $create_group_id);
  37. return $this->fill($data)->save();
  38. }
  39. public function getCreateGroupsByUid($uid) {
  40. $where = array('uid' => $uid, 'create_group_id !=' => 0);
  41. return $this->where($where)->getall('create_group_id');
  42. }
  43. public function getUniGroupsByUid($uid) {
  44. $where = array('uid' => $uid, 'uni_group_id !=' => 0);
  45. return $this->where($where)->getall('uni_group_id');
  46. }
  47. }