【发布时间】:2016-06-02 12:52:03
【问题描述】:
这是我的表结构。我想在提供的日期范围内获取记录。
|--------------|---------------------|
| 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();
【问题讨论】:
-
你得到了什么输出?
-
使用
$this->db->last_query()打印您的查询并检查您的查询返回什么 -
查询输出 SELECT
T.idFROM (touristT) WHERET.year>= 2015 ANDT.month>= 1 AND @987645 @.yearT.month -
以 03 01 格式查看月份
-
添加单引号和带 0 前缀的月份
标签: php mysql codeigniter activerecord