Group.php 1.7 KB

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