Codeigniter Active Record,多个条件

时间:2016-06-02 12:52:04

标签: php mysql codeigniter activerecord

这是我的表格结构。我希望在提供的日期范围之间获得记录。

static void a1()
{

   int choice;
   Scanner sc1 = new Scanner(System.in);
   System.out.println();
   System.out.print("Enter Part#: ");
   pa[count] = sc1.nextLine();

   System.out.println();
   System.out.print("Enter Make: ");
   ma[count] = sc1.nextLine();

   System.out.println();
   System.out.print("Enter description: ");
   so[count] = sc1.nextLine();

   System.out.println();
   System.out.print("Enter price: ");
   pr[count] = sc1.nextLine();

   ++count; 

 } 

我尝试了以下查询,但没有成功。

|--------------|---------------------|
|      id      |   year   |  month   |
|--------------|---------------------|
|      1       |    2015  |  01      |
|      2       |    2015  |  02      |
|      3       |    2016  |  02      |
|--------------|---------------------|

1 个答案:

答案 0 :(得分:0)

试试这个:

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