コード例 #1
0
 public function get_event_messages($event_id)
 {
     $this->db->select('em.id, em.created, em.message, u.id as author_id, u.username as author_username, u.birthday as author_birthday, u.gender as author_gender');
     $this->db->join($this->users_model->table . ' u', 'em.users_id = u.id');
     $this->db->where('em.events_id', $event_id);
     $messages = $this->db->get($this->table . ' em')->result_array();
     if (!$messages) {
         return [];
     }
     foreach ($messages as &$row) {
         $row['author_avatar'] = $this->users_model->get_photo($row['author_id'], $this->users_model->avatar);
     }
     return $messages;
 }
コード例 #2
0
 public function get_event_joined($event_id, $count = false)
 {
     $this->db->select('etu.created as join_date, u.id, u.username, u.birthday, u.gender');
     $this->db->join($this->users_model->table . ' u', 'etu.users_id = u.id');
     $this->db->where('etu.events_id', $event_id);
     if ($count) {
         return $this->db->count_all_results($this->table . ' etu');
     }
     $users = $this->db->get($this->table . ' etu')->result_array();
     if (!$users) {
         return [];
     }
     foreach ($users as &$row) {
         $row['avatar'] = $this->users_model->get_photo($row['id'], $this->users_model->avatar);
     }
     return $users;
 }
コード例 #3
0
ファイル: user.php プロジェクト: Speennaker/cometogether
 public function avatar_get()
 {
     $this->auth();
     try {
         $avatar = $this->model->get_photo($this->user_id, $this->model->avatar);
         $this->response($avatar, 200);
     } catch (Exception $e) {
         $this->response($e->getMessage(), $e->getCode());
     }
 }
コード例 #4
0
 public function get_my_joined($user_id)
 {
     $this->db->select("e.*, e.users_id as creator_id, u.username as creator_username, u.birthday as creator_birthday, u.gender as creator_gender,\n                (SELECT COUNT(etu.id) FROM {$this->etu_model->table} etu WHERE etu.events_id = e.id) as joined_count");
     $this->db->join($this->users_model->table . ' u', 'e.users_id = u.id');
     $this->db->join($this->etu_model->table . ' etu', 'etu.events_id = e.id', 'left');
     $this->db->where('etu.users_id', $user_id);
     $this->db->where('e.users_id !=', $user_id);
     $events = $this->db->get($this->table . ' e')->result_array();
     foreach ($events as &$event) {
         $event['creator_avatar'] = $this->users_model->get_photo($event['users_id'], $this->users_model->avatar);
         unset($event['users_id']);
         $event['place_info'] = json_decode($event['place_info']);
     }
     return $events;
 }