如何在逗号分隔的行值中使用 codeigniter
how to use codeigniter where in on comma seperated row values
我正在为我的项目使用 codeigniter 并实施搜索。我想从拥有汽车的用户 table 中过滤用户。这个table的结构如下所示
+-----+----------+---------------------+---------------+
| #id | username | cars | other_details |
+-----+----------+---------------------+---------------+
| 1 | MAC | Jaguar,Porche | -- |
| 2 | DEV | Porche,Ferrari,Ford | -- |
| 3 | MONICA | Ford,Audi | -- |
+-----+----------+---------------------+---------------+
在前端,我从返回汽车数组的复选框中选择汽车,以查找拥有这些汽车的用户,如 ["Porche"、"Ferrari"]。我无法找到如何让用户在模型中使用 codeigniter 活动记录的解决方案。请帮我找出如何让 users/rows 有可用的汽车阵列。
提前致谢。
我终于找到了答案。
首先我用逗号 (,) 对数组进行了内爆,然后使用 sql 查询和正则表达式来获得这样的答案;
$this->db->sql("select * from users where `cars` NOT REGEXP '$cars'");
这个查询按照我的要求给出数据。
我正在为我的项目使用 codeigniter 并实施搜索。我想从拥有汽车的用户 table 中过滤用户。这个table的结构如下所示
+-----+----------+---------------------+---------------+
| #id | username | cars | other_details |
+-----+----------+---------------------+---------------+
| 1 | MAC | Jaguar,Porche | -- |
| 2 | DEV | Porche,Ferrari,Ford | -- |
| 3 | MONICA | Ford,Audi | -- |
+-----+----------+---------------------+---------------+
在前端,我从返回汽车数组的复选框中选择汽车,以查找拥有这些汽车的用户,如 ["Porche"、"Ferrari"]。我无法找到如何让用户在模型中使用 codeigniter 活动记录的解决方案。请帮我找出如何让 users/rows 有可用的汽车阵列。 提前致谢。
我终于找到了答案。
首先我用逗号 (,) 对数组进行了内爆,然后使用 sql 查询和正则表达式来获得这样的答案;
$this->db->sql("select * from users where `cars` NOT REGEXP '$cars'");
这个查询按照我的要求给出数据。