【发布时间】:2017-02-20 08:45:59
【问题描述】:
我想知道如何使用 codeigniter 进行查询以显示我需要的计数?
EX:提交选择90和56
$this->db->where('atr_id', 90);
$this->db->or_where('atr_id', 56);
列表表
id | item_id | atr_id
---------------------------------------
1 | 1 | 56
2 | 1 | 90
3 | 2 | 56
4 | 2 | 90
5 | 2 | 92
预期回报如下所示。
item_id | active_attr | total_attr
----------------------------------------------
1 | 2 | 2 // active_attr (90,56) and total_attr (90 , 56)
2 | 2 | 3 // active_attr (90,56) and total_attr (90, 56, 92)
active_attr 计算在item_id 中找到的atr_id 的数量(90、56)
并且total_attr 计算atr_id 的总数item_id
这里真的需要帮助谢谢大家...
【问题讨论】:
-
您能否澄清一下
active_attr对item_id2 的结果是2 吗? -
@DarshanMehta
active_attr分别是 56 和 90 -
查看我的 CI 更新
标签: php mysql database codeigniter count