Hi,
I now have a further problem which is that i need to replace the destination ID with the destination name from the destinations table. I was advised that this would be v difficult in MYSQL so have gone the PHP route. SO far I have:
Code:
function index() {
$this->autoRender = false;
//$data = $this->Itinery->findAll(null,'ship_id,destination_ids',null,null,null,0);
$query = 'SELECT ship_id, GROUP_CONCAT(DISTINCT destination_ids) FROM itineries GROUP BY ship_id;';
$query2 = 'SELECT ship_name , GROUP_CONCAT(DISTINCT destination_ids ) FROM itineries,ships WHERE itineries.ship_id = ships.id GROUP BY ship_id;';
$data = $this->Itinery->query($query2);
//debug($data); exit;
$destNames = $this->Destination->findAll(null, 'id, destination_name');
$destination = array();
foreach ($data as $key => $value) {
//pr($value);
$temp_destination = explode(',', $value[0]['GROUP_CONCAT(DISTINCT destination_ids )']);
foreach ($temp_destination as $key) {
$destination[$key][] = $value['ships']['ship_name'];
}
}
asort($destNames,SORT_NUMERIC);
ksort($destination,SORT_NUMERIC);
//debug($destination);
echo "DESTINATION NAMES FROM DESTINATIONS TABLE<br />";
debug($destNames);
echo "RESULT OF QUERY FROM ITINERARIES TABLE<br />";
debug($destination);
}
}
I have tried looping through one array and assigning the value directly but got some weird results. The debug outputs are viewable here:
http://dev.insidecruise.co.uk/map
What I want is to replace the numeric key from the second lot of output with the destination name from the corresponding id in the first lot of output.
hope that makes sense. anyone got any thoughts on how best to do this?
thanks!
<L>
Bookmarks