我是 php 新手,我正在尝试编写一个函数,该函数将从reviews
mysql 表中获取所有结果。我已经发布了我尝试过的内容,但它说我在第 101 行有问题"$sql = 'SELECT * FROM reviews WHERE id = "'.$review_id.'";'"
,我看不出问题是什么,有人可以帮忙。我使用apigee测试api
/*reviews*/
function reviews_get() {
$this->load->database();
$sql = 'SELECT * FROM reviews;';
$query = $this->db->query($sql);
$data = $query->result();
$this->response($data, 200);
}
function review_get($review_id) {
$this->load->database();
$sql = 'SELECT * FROM reviews WHERE id = "'.$review_id.'";';
$query = $this->db->query($sql);
$data = $query->row();
$this->response($data, 200);
}