将数组传递到 Codeigniter Active Record 中的位置 [英] Pass array to where in Codeigniter Active Record

查看:35
本文介绍了将数组传递到 Codeigniter Active Record 中的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库中有一个包含 adminId 和 clientId 的表

I have a table in my database with adminId and clientId

登录用户的 adminId 可能有 20 条记录,我正在尝试提取客户列表.

There might be 20 records with the adminId of the logged in user and I'm trying to pull a list of clients.

我想知道是否有一种方法可以说:

I am wondering if there is a way i can say something like:

$this->db->where('id', '20 || 15 || 22 || 46 || 86');

我正在尝试使用动态数据执行此操作(您永远不知道需要提取多少个客户端 ID).有什么想法吗?

I'm trying to do this with dynamic data (you never know how many clients Id's you'll need to pull). Any ideas?

推荐答案

$this->db->where_in('id', ['20','15','22','42','86']);

参考:where_in

这篇关于将数组传递到 Codeigniter Active Record 中的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆