/** * Populates the collection of business objects from raw data * * @return bool * @param MySqlRawData $result */ protected function BuildItems(MySqlRawData $result) { # use CollectionBuilder to handle duplicates $club_builder = new CollectionBuilder(); $club = null; while ($row = $result->fetch()) { # check whether this is a new club if (!$club_builder->IsDone($row->club_id)) { # store any exisiting club if ($club != null) { $this->Add($club); } # create the new club $club = new Club($this->GetSettings()); $club->SetId($row->club_id); $club->SetName($row->club_name); $club->SetTypeOfClub($row->club_type); $club->SetHowManyPlayers($row->how_many_players); $club->SetAgeRangeLower($row->age_range_lower); $club->SetAgeRangeUpper($row->age_range_upper); $club->SetPlaysOutdoors($row->plays_outdoors); $club->SetPlaysIndoors($row->plays_indoors); $club->SetShortUrl($row->short_url); $club->SetTwitterAccount($row->twitter); $club->SetFacebookUrl($row->facebook); $club->SetInstagramAccount($row->instagram); $club->SetClubmarkAccredited($row->clubmark); } # team the only cause of multiple rows (so far) so add to current club if ($row->team_id) { $team = new Team($this->GetSettings()); $team->SetId($row->team_id); $team->SetName($row->team_name); $team->SetShortUrl($row->team_short_url); $club->Add($team); } } # store final club if ($club != null) { $this->Add($club); } }