/** * Returns an instance of class (singleton pattern implementation). * * @return BOL_UserFeaturedDao */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
public function isUserFeatured($id) { $dto = $this->userFeaturedDao->findByUserId($id); return !empty($dto); }
public function countFeatured() { $queryParts = $this->getUserQueryFilter("u", "id", array("method" => "BOL_UserDao::countFeatured")); $query = "SELECT COUNT(*) FROM `{$this->getTableName()}` AS `u`\n {$queryParts["join"]}\n INNER JOIN `" . BOL_UserFeaturedDao::getInstance()->getTableName() . "` AS `f`\n ON( `u`.`id` = `f`.`userId` )\n WHERE {$queryParts["where"]}"; // cached featured users count query $cacheLifeTime = self::CACHE_LIFE_TIME; $tag = array(self::CACHE_TAG_FEATURED_LIST, self::CACHE_TAG_ALL_USER_LIST); return $this->dbo->queryForColumn($query, null, $cacheLifeTime, $tag); }
public function findFeaturedList($count, $withPhoto = true) { $avatarJoin = !$withPhoto ? '' : "INNER JOIN `" . BOL_AvatarDao::getInstance()->getTableName() . "` as `a`\n \t\t\tON( `u`.`id` = `a`.`userId` )"; $query = "\n SELECT `u`.* FROM `{$this->getTableName()}` AS `u`\n\n INNER JOIN `" . BOL_UserFeaturedDao::getInstance()->getTableName() . "` AS `f`\n ON( `u`.`id` = `f`.`userId` )\n\n LEFT JOIN `" . BOL_UserSuspendDao::getInstance()->getTableName() . "` as `s`\n ON( `u`.`id` = `s`.`userId` )\n\n LEFT JOIN `" . BOL_UserApproveDao::getInstance()->getTableName() . "` as `d`\n ON( `u`.`id` = `d`.`userId` )\n\n {$avatarJoin}\n\n WHERE `s`.`id` IS NULL AND `d`.`id` IS NULL\n ORDER BY `u`.`activityStamp` DESC\n LIMIT ?,?\n "; return $this->dbo->queryForObjectList($query, $this->getDtoClassName(), array(0, $count)); }