如何使用 codeigniter 在 where 子句中传递数组变量? 例如,使用如下 SQL 查询:
Select(" item,price Where(userid=123 and proid=3 or userid=124 and proid=3... [upto n user id]userid=nth_id and proid=3");
如果 userid 存储在数组变量中,那么如何在 codeigniter 中创建这样的条件?
最佳答案
我正在寻找这个,它应该寻找数组中的 userid
并且 proid
为 3。我还没有测试过它,但让我们知道您过得怎么样。
$array = array( '123', '124' );
$this->db
->select( 'item, price' )
->from( 'table')
->where( 'proid', '3' )
->where_in( 'userid', $array )
->get();
$result = $query->result();
关于php - 如何使用 codeigniter 在 where 子句中传递数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40383535/