我想要以下功能来选择具有特定$minvalue和$maxvalue之间的住宿的酒店.什么是最好的方式呢?
- function gethotels($state_id,$city,$accommodation,$minvalue,$maxvalue,$limit,$pgoffset)
- {
- $this->db->limit($limit,$pgoffset);
- $this->db->order_by("id","desc");
- $this->db->where('state_id',$state_id);
- $this->db->where('city',$city);
- // This one should become a between selector
- $this->db->where($accommodation,$minvalue);
- $result_hotels = $this->db->get('hotels');
- return $result_hotels->result();
- }
你应该使用
- $this->db->where('$accommodation >=',minvalue);
- $this->db->where('$accommodation <=',maxvalue);
我不确定语法,所以如果不正确,请求赦免.
无论如何,BETWEEN使用> = min&&&& < =最大
这是我的例子的意思.
编辑:
看着this link我想你可以写:
- $this->db->where("$accommodation BETWEEN $minvalue AND $maxvalue");