/** * Returns an instance of class (singleton pattern implementation). * * @return EVENT_BOL_EventDao */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
public function findEvents($past, $kw, $userId, $limit = null) { $eventDao = EVENT_BOL_EventDao::getInstance(); $eventUserDao = EVENT_BOL_EventUserDao::getInstance(); $params = array('startTime' => time(), 'endTime' => time(), 'u' => $userId, 's' => EVENT_BOL_EventUserDao::VALUE_STATUS_YES); if (!empty($kw)) { $params["kw"] = "%" . $kw . "%"; } $limitStr = $limit === null ? '' : 'LIMIT 0, ' . intval($limit); $kwWhere = empty($kw) ? "1" : "e.title LIKE :kw"; $order = "e.`startTimeStamp` " . ($past ? "DESC" : ""); $query = "SELECT e.* FROM `" . $eventDao->getTableName() . "` e \n INNER JOIN " . $eventUserDao->getTableName() . " u ON u.eventId=e.id AND u.status=:s\n WHERE u.userId!=:u AND e.userId=:u AND " . $this->getTimeClause($past, "e") . " AND " . $kwWhere . "\n ORDER BY {$order} {$limitStr}"; return OW::getDbo()->queryForObjectList($query, $eventDao->getDtoClassName(), $params); }
public function findByIdList($idList) { return $this->eventDao->findByIdList($idList); }
/** * @param integer $eventId */ public function findUserListForInvite($eventId, $first, $count, $friendList = null) { $userDao = BOL_UserDao::getInstance(); $eventDao = EVENT_BOL_EventDao::getInstance(); $eventUserDao = EVENT_BOL_EventUserDao::getInstance(); $where = ""; if (isset($friendList) && empty($friendList)) { return array(); } else { if (!empty($friendList)) { $where = " AND `u`.id IN ( " . $this->dbo->mergeInClause($friendList) . " ) "; } } $queryParts = BOL_UserDao::getInstance()->getUserQueryFilter("u", "id", array("method" => "EVENT_BOL_EventUserDao::findUserListForInvite")); $query = "SELECT `u`.`id`\r\n \t\tFROM `{$userDao->getTableName()}` as `u`\r\n " . $queryParts['join'] . "\r\n \r\n LEFT JOIN `" . $eventDao->getTableName() . "` as `e`\r\n \t\t\tON( `u`.`id` = `e`.`userId` AND e.id = :event )\r\n \r\n LEFT JOIN `" . $this->getTableName() . "` as `ei`\r\n \t\t\tON( `u`.`id` = `ei`.`userId` AND `ei`.eventId = :event )\r\n\r\n LEFT JOIN `" . $eventUserDao->getTableName() . "` as `eu`\r\n \t\t\tON( `u`.`id` = `eu`.`userId` AND `eu`.eventId = :event )\r\n\r\n \t\tWHERE " . $queryParts['where'] . " AND `e`.`id` IS NULL AND `ei`.`id` IS NULL AND `eu`.`id` IS NULL " . $where . "\r\n \t\tORDER BY `u`.`activityStamp` DESC\r\n \t\tLIMIT :first, :count "; return $this->dbo->queryForColumnList($query, array('event' => $eventId, 'first' => $first, 'count' => $count)); }