private static function getMyCommunityEvent($startday = null, $endday = null, $targetDay = null, $is_setKeydate = true, Community $community = null) { $memberId = self::getMyId(); if (is_null(self::$communityMemberIds)) { self::$communityMemberIds = array(); if (null === $community) { $communityMembers = Doctrine::getTable('CommunityMember')->createQuery()->select('community_id')->where('member_id = ?', (int) $memberId)->andWhere('is_pre = ?', false)->execute(array(), Doctrine::HYDRATE_NONE); foreach ($communityMembers as $communityMember) { self::$communityMemberIds[] = $communityMember[0]; } } else { self::$communityMemberIds[] = $community->id; } } if (!count(self::$communityMemberIds)) { return array(); } $q = Doctrine::getTable('CommunityEvent')->createQuery()->select('id, name, DATE(open_date)')->whereIn('community_id', self::$communityMemberIds); if ($targetDay) { $q->andWhere('open_date = ?', $targetDay); } else { $q->andWhere('open_date >= ?', $startday)->andWhere('open_date <= ?', $endday); } $communityEvents = $q->execute(array(), Doctrine::HYDRATE_NONE); if (!count($communityEvents)) { return array(); } if (is_null(self::$joinEvents)) { $communityEventMembers = Doctrine::getTable('CommunityEventMember')->createQuery()->select('community_event_id')->where('member_id = ?', $memberId)->execute(array(), Doctrine::HYDRATE_NONE); self::$joinEvents = array(); foreach ($communityEventMembers as $communityEventMember) { self::$joinEvents[$communityEventMember[0]] = true; } } $results = array(); foreach ($communityEvents as $communityEvent) { $data = array('is_join' => isset(self::$joinEvents[$communityEvent[0]]) ? true : false, 'id' => $communityEvent[0], 'name' => $communityEvent[1]); if ($is_setKeydate) { $results[$communityEvent[2]][] = $data; } else { $results[] = $data; } } return $results; }