TA获取增加条数条件

mobile-first
赵鹏 5 years ago
parent e0fdfdd257
commit 1947e6f86a

@ -435,6 +435,10 @@ class Index extends CI_Controller {
exit('{"status":"404","reason":"请输入站点代码!"}'); exit('{"status":"404","reason":"请输入站点代码!"}');
}else{ }else{
$product_code = $this->input->get_post('productCode'); $product_code = $this->input->get_post('productCode');
$num = $this->input->get_post("num");
if (!isset($num)){
$num=5;
}
if(empty($product_code)){ if(empty($product_code)){
$return_data = array(); $return_data = array();
@ -448,7 +452,7 @@ class Index extends CI_Controller {
} }
//根据站点获取评论 //根据站点获取评论
$list_reviews = $this->Tripadvisor_Review_model->get_fivelatestreviews($destination,$product_code); $list_reviews = $this->Tripadvisor_Review_model->get_fivelatestreviews($destination,$product_code,$num);
$return_data['list_reviews'] = $list_reviews; $return_data['list_reviews'] = $list_reviews;
print_r(json_encode($return_data)); print_r(json_encode($return_data));
} }

@ -198,13 +198,13 @@ class Tripadvisor_Review_model extends CI_Model {
return $query->result(); return $query->result();
} }
public function get_fivelatestreviews($destination,$product_code=null){ public function get_fivelatestreviews($destination,$product_code=null,$num=5){
if(!empty($product_code)){ if(!empty($product_code)){
$where = "and tr_product_code = '{$product_code}'"; $where = "and tr_product_code = '{$product_code}'";
}else{ }else{
$where = ''; $where = '';
} }
$sql = "select top 5 $sql = "select top ".$num."
* *
from Ta_Reviews where tr_destination = ? {$where} and tr_member_starts = '5' order by tr_review_date desc"; from Ta_Reviews where tr_destination = ? {$where} and tr_member_starts = '5' order by tr_review_date desc";
$query = $this->INFO->query($sql,array($destination)); $query = $this->INFO->query($sql,array($destination));

Loading…
Cancel
Save