Ejemplo n.º 1
0
 public function getRelatedDestination($poi_id)
 {
     $table_area = new Model_DbTable_Area();
     $table_areatopoi = new Model_DbTable_AreaToPoi();
     $area_list = $table_areatopoi->getPoiAreaIdProvince($poi_id, 1);
     $poi_list = array();
     foreach ($area_list as $area_id) {
         $temp = $table_areatopoi->getAllPoiByAreaIdExPoi($area_id, $poi_id);
         foreach ($temp as $temp_poi) {
             if (!in_array($temp_poi, $poi_list)) {
                 array_push($poi_list, $temp_poi);
             }
         }
     }
     if (sizeof($poi_list) < 5) {
         $area_list = $table_areatopoi->getPoiAreaIdProvince($poi_id);
         foreach ($area_list as $area_id) {
             $temp = $table_areatopoi->getAllPoiByAreaIdExPoi($area_id, $poi_id);
             foreach ($temp as $temp_poi) {
                 if (!in_array($temp_poi, $poi_list)) {
                     array_push($poi_list, $temp_poi);
                 }
             }
         }
     }
     if (sizeof($poi_list) > 5) {
         $treshold = 5;
     } else {
         $treshold = sizeof($poi_list);
     }
     $random = $this->_mrand(0, $treshold - 1, $treshold);
     $random_list = array();
     foreach ($random as $index) {
         array_push($random_list, $poi_list[$index]);
     }
     return $random_list;
 }