I have a site where a user can serach hotel rooms in all over the world.
I make a request to some server and retrieve xml response.
I parse every xml and print hotel, image and combinations of room (because if someone search a single room and a dobule room and a triple room I have more combinations).
Well, the problem is that I can retrieve many and many hotel and every hotel can have more type of room like 5 for each hotel (with 5 kind of room I can have 7 / 8 combination calculated in php).
I put every hotel and rooms in an array that pass to my view, this is my array constructor (I have a cut a lot of informations):
$hotel = array();
foreach ($xml->DATA as $entry){
foreach ($entry->HOTEL_DATA as $entry2){
$id = (string)$entry2->attributes()->HOTEL_CODE;
$hotel_array2 = array();
$hotel_array2['id'] = $id;
$hotel_array2['currency'] = (string)$entry2->attributes()->CURRENCY_CODE;
$i=0;
foreach($entry2->ROOM_DATA as $room){
$room_array = array();
$room_array['id'] = (string)$room->attributes()->CCHARGES_CODE;
$room_array['code'] = (string)$room->attributes()->ROOM_CODE;
$room_array['name'] = utf8_decode($room->ROOM_NAME);
$hotel_array2['rooms'][$i] = array($room_array);
$i++;
}
if (!isset($hotel_array[$hotel_array2['id']])) {
$hotel_array[$hotel_array2['id']] = $hotel_array2;
} else {
$hotel_array[$hotel_array2['id']]['rooms'] = array_merge($hotel_array[$hotel_array2['id']]['rooms'], $hotel_array2['rooms']);
}
}
}
}
return ($hotel_array);
To print this array I have to make some foreach inside it (about 3, 4) and calculate each combination of rooms that correspond to the user search.
The oriblem is that the I take 30 second to retrieve data and print it (a lot of time) but the problem is that I have to insert many other provider (server to take hotel then more hotel) and if a user have to ordinate by price or by location, order this array with many level is very slowly I think and I have to pass by post this array every time.,
I have thinked a solution:
Store all data into a database in some table: hotel, rooms and viuew only some hotel (20 maximum) and if I have to order it I makle another query that search inside this table (every table is a search or have an external key that correspond to this search).
Is a good way to store data search inside it and after print or ios better to have a very big array woth many foreach and pass every time in Post this?
Is there other solutions?
Is a question about architectural and, how to store (if I have to store data), how to print, how to MANAGE a lot of data I have no experience with this amount of data.