本文整理汇总了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;
}