【问题标题】:Add multiple values in where clause in grocery crud在杂货杂货的 where 子句中添加多个值
【发布时间】:2013-05-03 13:33:35
【问题描述】:

我想在 where 子句中添加多个值。

------------就像在 Sql 中,我们这样做------

SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1,value2,...)

如何在杂货中使用它?

【问题讨论】:

    标签: codeigniter where-clause where-in grocery-crud


    【解决方案1】:

    GroceryCrud 中的 WHERE 子句的工作方式与 codeigniter 的 WHERE 子句完全相同:

    $this->db->where_in('columnname', $arrayvalues);
    

    希望这对您有所帮助,请不要犹豫,进一步提问 =)

    GroceryCrud 文档WHERE

    【讨论】:

      【解决方案2】:

      使用or_where 而不是where

      例如

      function example_with_or_where() {
      
          $crud = new grocery_CRUD();
      
          $crud->where('productName','Motorcycle');
          $crud->or_where('productName','Car');
          $crud->or_where('productName','Bicycle');
      
          $crud->set_table('products');
          $crud->columns('productName','buyPrice');
      
          $output = $crud->render();
      
          $this->_example_output($output);
      }
      

      详情here

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-10-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多