Group.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. 'owner_uid',
  12. 'name',
  13. 'uniacid',
  14. 'modules',
  15. 'templates',
  16. 'uid',
  17. );
  18. protected $default = array(
  19. 'owner_uid' => '0',
  20. 'name' => '',
  21. 'uniacid' => '0',
  22. 'modules' => '',
  23. 'templates' => '',
  24. 'uid' => '0',
  25. );
  26. public function getById($id) {
  27. $data = $this->where('id', $id)->get();
  28. if (!empty($data['modules'])) {
  29. $data['modules'] = iunserializer($data['modules']);
  30. }
  31. if (!empty($data['templates'])) {
  32. $data['templates'] = iunserializer($data['templates']);
  33. }
  34. return $data;
  35. }
  36. public function getData($key) {
  37. $data = $this->getall($key);
  38. if (!empty($data)) {
  39. foreach ($data as &$row) {
  40. if (!empty($row['modules'])) {
  41. $row['modules'] = iunserializer($row['modules']);
  42. }
  43. if (!empty($row['templates'])) {
  44. $row['templates'] = iunserializer($row['templates']);
  45. }
  46. }
  47. }
  48. return $data;
  49. }
  50. public function searchWithUniacidAndUid($uniacid = 0, $uid = 0) {
  51. return $this->where('u.uniacid', $uniacid)->where('u.uid', $uid);
  52. }
  53. public function searchWithName($name) {
  54. return $this->query->where('u.name LIKE', "%{$name}%");
  55. }
  56. public function searchWithFounderUid($founder_uid) {
  57. return $this->query
  58. ->select('u.*, f.founder_uid, f.uni_group_id')
  59. ->leftjoin('users_founder_own_uni_groups', 'f')
  60. ->on(array('u.id' => 'f.uni_group_id'))
  61. ->where('f.founder_uid', $founder_uid);
  62. }
  63. public function getUniGroupList() {
  64. return $this->query
  65. ->from('uni_group', 'u')
  66. ->getall('u.id');
  67. }
  68. }