include 'common.class.php'; class Recommon extends Common { public $data; function __construct() { parent::__construct(); } public function get_trip() { $sql = "SELECT * FROM ft_view WHERE view_name = :view_name "; $stmt = $this->db->prepare($sql); $stmt->execute(array(':view_name' => $_POST['view_name'])); $stmt->setFetchMode(PDO::FETCH_ASSOC); $res = $stmt->fetch(); if ($res) { $this->res['code'] = 0; $this->res['message'] = 'success'; $this->res['spot'] = $res; } else { $this->res['code'] = 1; $this->res['message'] = 'fail! No spot_id'; } } function __destruct() { $this->die_json($this->res); } } $recommend = new Recommon(); $recommend->get_trip();
public function get_views() { $spot_id = $this->get_spot(); var_dump($spot_id); die; $stmt = $this->db->prepare("select * from ft_view where spot_id=:spot_id LIMIT " . $this->num); $stmt->execute(array(':spot_id' => $spot_id)); $stmt->setFetchMode(PDO::FETCH_ASSOC); //设置获取模式 $res = $stmt->fetchAll(); if ($res) { $this->data['spotList'] = $res; } else { $this->data['spotList'] = 0; } } function __destruct() { if ($this->data['spotList']) { $this->data['code'] = 0; $this->data['message'] = 'success'; $this->die_json($this->data); } else { $this->data['code'] = -1; $this->data['message'] = 'fail'; $this->die_json($this->data); } } } $recommend = new Recommon(); $recommend->get_views();