Php Codeigniter活动记录,多个where条件

Php Codeigniter活动记录,多个where条件,php,mysql,codeigniter,activerecord,Php,Mysql,Codeigniter,Activerecord,这是我的桌子结构。我想获取提供的日期范围之间的记录 |--------------|---------------------| | id | year | month | |--------------|---------------------| | 1 | 2015 | 01 | | 2 | 2015 | 02 | | 3 | 2016 |

这是我的桌子结构。我想获取提供的日期范围之间的记录

|--------------|---------------------|
|      id      |   year   |  month   |
|--------------|---------------------|
|      1       |    2015  |  01      |
|      2       |    2015  |  02      |
|      3       |    2016  |  02      |
|--------------|---------------------|
我尝试了以下查询,但没有成功

return $this->db->select('*')
                ->from('tourist T')
                ->where('T.year >=', $where['s_year'])
                ->where('T.month >=', $where['s_month'])
                ->where('T.year <=', $where['e_year'])                            
                ->where('T.month <=', $where['e_month'])
                ->get()->result();
return$this->db->select('*'))
->从('T'游客)
->其中('T.year>=',$where['s_year'])
->其中('T.month>=',$where['s_month'])
->其中('T.year试试这个:

   $this->db->select('*')
            ->from('test T')
            ->where('T.year >='.$where['s_year'].' and T.month >='.$where['s_month'])
            ->where('T.year <='.$where['s_year'].' and T.month <='.$where['s_month'])
            ->get()->result();
$this->db->select('*'))
->from('test T')
->其中('T.year>='.$where['s_year'.'和T.month>='.$where['s_year'.]))
->其中('T.year试试这个:

   $this->db->select('*')
            ->from('test T')
            ->where('T.year >='.$where['s_year'].' and T.month >='.$where['s_month'])
            ->where('T.year <='.$where['s_year'].' and T.month <='.$where['s_month'])
            ->get()->result();
$this->db->select('*'))
->from('test T')
->其中('T.year>='.$where['s_year'.'和T.month>='.$where['s_year'.]))


->where('T.year您得到的输出是什么?使用
$this->db->last_query()
打印您的查询并检查查询返回的内容查询输出选择
T
id
来源(
tourism
T)其中
T
year
=2015和
T
=1和
T
year
以03 01格式检查月份添加单引号和带0前缀的月份您得到的输出是什么?使用
$this->db->last\u query()
要打印查询并检查查询返回的内容,请选择
T
id
FROM(
tourism
T)其中
T
year
=2015和
T
month
=1和
T
year
检查03 01格式中的月份添加单引号和带0前缀的月份这是查询输出选择
T
*FROM(
T
T)和
T
year
=2015和T.month>=1和
T
year
您需要使用括号:选择T.*FROM(游客T)where(T.year>=2015和T.month>=1)和(T.year>=1谢谢您的回复,如果我想添加其他where子句,如$this->->db->SELECT('*')->FROM('test T')->->where(T.country'id,'13'))->where('T.year>='.$where['s_'year'.]和T.month>='.$where['s_'month'.])->where('T.year您需要这样做:$this->db->select('*')->from('test T')->where('T.country_id=13和T.year>='.$where['s_'year'.]和T.month>=.$where['s_'month'.])->在哪里('T.country\u id=13和T.year谢谢,保存了我的一天。这是查询输出,从(
tourism
T)和
T
year
=2015和T.month>=1和
T
year
中选择T.*,其中(T.year>=2015和T.month>=1)和(T.year感谢您的回复,如果我想添加其他where子句,比如$this->db->select('*')->from('test T')->where(T.country_id,'13')->where('T.year>='.$where['s_year'].$where['s_month'])->where('T.year您需要这样做:$this->db->select('*')->from('test T T T T T T T T T T')->where('T.country\u id=13和T.year>='.$where['s\u year'.'和T.month>='.$where['s\u month'])->where('T.country\u id=13和T.year谢谢,救了我一天。