微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – 在WHERE条件下使用BETWEEN

我想要以下功能来选择具有特定$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");

原文地址:https://www.jb51.cc/php/132130.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐