當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Generic::getRestaurant方法代碼示例

本文整理匯總了PHP中Generic::getRestaurant方法的典型用法代碼示例。如果您正苦於以下問題:PHP Generic::getRestaurant方法的具體用法?PHP Generic::getRestaurant怎麽用?PHP Generic::getRestaurant使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Generic的用法示例。


在下文中一共展示了Generic::getRestaurant方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: recommendationRestoWS

 public function recommendationRestoWS()
 {
     if (Efiwebsetting::getData('checkOAuth') == 'yes') {
         IMBAuth::checkOAuth();
     }
     $lat = isset($_GET['latitude']) ? addslashes($_GET['latitude']) : "";
     if ($lat == "" or !$lat) {
         $lat = MenuRevoConstants::$latitude;
     }
     if (!Generic::checkLatitude($lat)) {
         Generic::errorMsg("Latitude must be Numeric!");
     }
     $long = isset($_GET['longitude']) ? addslashes($_GET['longitude']) : "";
     if ($long == "" or !$long) {
         $long = MenuRevoConstants::$longitude;
     }
     if (!Generic::checklongitude($long)) {
         Generic::errorMsg("Longitude must be Numeric!");
     }
     $distance = isset($_GET['distance']) ? addslashes($_GET['distance']) : 20;
     if ($distance == '') {
         $distance = 20;
     }
     $page = addslashes($_GET['page']);
     if ($page == "" || $page < 1) {
         $json['status_code'] = 0;
         $json['status_message'] = "No Page Found";
         echo json_encode($json);
         die;
     }
     $limit = addslashes($_GET['limit']);
     if ($limit == "" || $limit < 1) {
         $json['status_code'] = 0;
         $json['status_message'] = "Limit Error";
         echo json_encode($json);
         die;
     }
     $begin = ($page - 1) * $limit;
     $json = array();
     $json['status_code'] = 1;
     global $db;
     $objRecommendation = new RecommendationModel();
     $objRestaurant = new MasterRestaurantModel();
     $qdish = "SELECT recom.*, SQRT(POW(69.1 * (resto.latitude - {$lat}), 2) + POW(69.1 * ({$long} - resto.longitude) * COS(resto.latitude / 57.3), 2)) AS distance FROM {$objRecommendation->table_name} recom LEFT JOIN {$objRestaurant->table_name} resto ON  resto.id_restaurant= recom.id_restaurant AND DATE(recom.end) >= DATE(NOW()) AND DATE(recom.start)<= DATE(NOW())HAVING distance < {$distance} ORDER BY distance LIMIT {$begin},{$limit}";
     $arrRecom = $db->query($qdish, 2);
     //        if (count($arrRecom) == 0) {
     //            $json['status_code'] = 0;
     //            $json['status_message'] = "No ID Found";
     //            echo json_encode($json);
     //            die();
     //        }
     $json['results']['restaurant'] = array();
     foreach ($arrRecom as $recom) {
         $resto = Generic::getRestaurant($recom->id_restaurant);
         $resto['distance'] = $recom->distance;
         $json['results']['restaurant'][] = $resto;
     }
     echo json_encode($json);
     die;
 }
開發者ID:CapsuleCorpIndonesia,項目名稱:martabak_revolution,代碼行數:60,代碼來源:Recommendation.php


注:本文中的Generic::getRestaurant方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。