Group.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 Group extends \We7Table {
  8. protected $tableName = 'users_group';
  9. protected $primaryKey = 'id';
  10. protected $field = array(
  11. 'owner_uid',
  12. 'name',
  13. 'package',
  14. 'maxaccount',
  15. 'timelimit',
  16. 'maxwxapp',
  17. 'maxwebapp',
  18. 'maxphoneapp',
  19. 'maxxzapp',
  20. 'maxaliapp',
  21. 'maxbaiduapp',
  22. 'maxtoutiaoapp',
  23. );
  24. protected $default = array(
  25. 'owner_uid' => '0',
  26. 'name' => '',
  27. 'package' => '',
  28. 'maxaccount' => '0',
  29. 'timelimit' => '0',
  30. 'maxwxapp' => '',
  31. 'maxwebapp' => '0',
  32. 'maxphoneapp' => '0',
  33. 'maxxzapp' => '0',
  34. 'maxaliapp' => '0',
  35. 'maxbaiduapp' => '0',
  36. 'maxtoutiaoapp' => '0',
  37. );
  38. public function getAllById($ids) {
  39. $data = $this->where('id', $ids)->getall('id');
  40. if (!empty($data)) {
  41. foreach ($data as &$item) {
  42. $item['package'] = iunserializer($item['package']);
  43. }
  44. }
  45. return $data;
  46. }
  47. public function searchWithNameLike($name) {
  48. return $this->where('u.name LIKE', "%{$name}%");
  49. }
  50. public function searchWithName($name) {
  51. return $this->where('u.name', $name);
  52. }
  53. public function searchWithNoId($id) {
  54. $this->query->where('u.id !=', $id);
  55. return $this;
  56. }
  57. public function getUsersGroupList() {
  58. return $this->query->from('users_group', 'u')
  59. ->getall('u.id');
  60. }
  61. public function getOwnUsersGroupsList($founder_uid) {
  62. return $this->query
  63. ->select('f.id as fid, u.*')
  64. ->leftjoin('users_founder_own_users_groups', 'f')
  65. ->on(array('u.id' => 'f.users_group_id'))
  66. ->where('f.founder_uid', $founder_uid);
  67. }
  68. }