Group.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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\Uni;
  7. class Group extends \We7Table {
  8. protected $tableName = 'uni_group';
  9. protected $primaryKey = 'id';
  10. protected $field = array(
  11. 'name',
  12. 'uniacid',
  13. 'modules',
  14. 'templates',
  15. 'uid',
  16. );
  17. protected $default = array(
  18. 'name' => '',
  19. 'uniacid' => '0',
  20. 'modules' => '',
  21. 'templates' => '',
  22. 'uid' => '0',
  23. );
  24. public function getData($key) {
  25. $data = $this->getall($key);
  26. if (!empty($data)) {
  27. foreach ($data as &$row) {
  28. if (!empty($row['modules'])) {
  29. $row['modules'] = iunserializer($row['modules']);
  30. }
  31. if (!empty($row['templates'])) {
  32. $row['templates'] = iunserializer($row['templates']);
  33. }
  34. }
  35. }
  36. return $data;
  37. }
  38. public function searchWithUid($uid = 0) {
  39. return $this->where('u.uid', $uid);
  40. }
  41. public function searchWithName($name) {
  42. return $this->query->where('u.name LIKE', "%{$name}%");
  43. }
  44. public function searchWithFounderUid($founder_uid) {
  45. return $this->query
  46. ->select('u.*, f.founder_uid, f.uni_group_id')
  47. ->leftjoin('users_founder_own_uni_groups', 'f')
  48. ->on(array('u.id' => 'f.uni_group_id'))
  49. ->where('f.founder_uid', $founder_uid);
  50. }
  51. public function getUniGroupList() {
  52. return $this->query
  53. ->from('uni_group', 'u')
  54. ->getall('u.id');
  55. }
  56. }