如何在Codeigniter中使用for循环的条件(How to give where condition using for loop in Codeigniter)

编程入门 行业动态 更新时间:2024-10-27 22:18:54
如何在Codeigniter中使用for循环的条件(How to give where condition using for loop in Codeigniter)

我有一个数组:

Array ( [0] => 9055954 [1] => 2736738 [2] => 1234 [3] => 2844725 )

我需要一个where条件来选择ids表数据库表add_family的ID不等于任何一个数组中的值,我使用codeigniter,我怎么能检查它使用循环for where条件。

I have an array:

Array ( [0] => 9055954 [1] => 2736738 [2] => 1234 [3] => 2844725 )

I need to a where condition to select the ids form database table add_family whose id is not equal to any one of the value in array, I'm using codeigniter, how can I check it using for loop for where condition.

最满意答案

您并不需要运行for循环来执行此操作。 你可以简单地通过运行一个简单的查询来检查它,这个查询将在排除数组后指定的所有记录之后进行检查:

$ignore_ids = [9055954, 2736738, 1234, 2844725]; $this->db->where_not_in('add_family', $ignore_ids);

You don't really need to run a for loop to do this. You can simply check it by running a simple query which will select all records from table after excluding ids as specified in array:

$ignore_ids = [9055954, 2736738, 1234, 2844725]; $this->db->where_not_in('add_family', $ignore_ids);

更多推荐

本文发布于:2023-07-28 16:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1306860.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:条件   如何在   Codeigniter   loop   give

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!