php - Codeigniter Active Record,多个 where 条件

标签 php mysql codeigniter activerecord

这是我的表结构。我想在提供的日期范围内获取记录。

|--------------|---------------------|
|      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->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();

关于php - Codeigniter Active Record,多个 where 条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37592430/

相关文章:

php - 如何从 Windows 中的 PHP 函数 exec() 获取 PID?

MySQL:存储来自可能在表单上显示可变时间的字段的值

php - Codeigniter - 在环境之间切换

php - 在 codeigniter PHP 中使用数组检查索引键

php - 在php中使用基于复选框的foreach将数据插入到两个表中

php - 我的脚本如何同时耗尽内存和执行时间?

java - Hibernate如果@NotFound,插入数据库

php - mysql分组选择最近的日期

mysql - 从 2 个表中检索匹配和不匹配的行

mysql - AWS 2x.large 服务器 Apache 和 Mysql 配置没有很好地利用 CPU 和内存