[英]how can i pass array in where clause with codeigniter?
How can I pass an array variable in where clause with codeigniter? 如何使用Codeigniter在where子句中传递数组变量? For example with a SQL query like: 例如,使用以下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");
If userid is stored in an array variable then how can I create such a condition in codeigniter? 如果userid存储在数组变量中,那么如何在codeigniter中创建这样的条件?
I you are looking for this, it should look for a userid
that is in the array and also has a proid
of 3. I have not tested it but let us know how you get on. 我正在寻找这个对象,它应该寻找数组中的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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.