FounderOwnCreateGroups.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 FounderOwnCreateGroups extends \We7Table {
  8. protected $tableName = 'users_founder_own_create_groups';
  9. protected $primaryKey = 'id';
  10. protected $field = array(
  11. 'founder_uid',
  12. 'create_group_id',
  13. );
  14. protected $default = array(
  15. 'founder_uid' => '',
  16. 'create_group_id' => '',
  17. );
  18. public function addOwnCreateGroup($founder_uid, $create_group_id) {
  19. $fill = array(
  20. 'founder_uid' => $founder_uid,
  21. 'create_group_id' => $create_group_id,
  22. );
  23. return $this->fill($fill)->save();
  24. }
  25. public function getallGroupsByFounderUid($founder_uid) {
  26. return $this->getQuery()
  27. ->select('*')
  28. ->from('users_founder_own_create_groups', 'o')
  29. ->innerjoin('users_create_group', 'c')
  30. ->on(array('o.create_group_id' => 'c.id'))
  31. ->where('o.founder_uid', $founder_uid)
  32. ->getall();
  33. }
  34. public function getGroupsByFounderUid($founder_uid, $pageindex, $pagesize = 15) {
  35. $groups = $this->getQuery()
  36. ->select('*')
  37. ->from('users_founder_own_create_groups', 'o')
  38. ->leftjoin('users_create_group', 'c')
  39. ->on(array('o.create_group_id' => 'c.id'))
  40. ->where('o.founder_uid', $founder_uid)
  41. ->page($pageindex, $pagesize)
  42. ->getall();
  43. $total = $this->getLastQueryTotal();
  44. return array('groups' => $groups, 'total' => $total);
  45. }
  46. }