distinct - 如何在不同的codeigniter中显示归档
问题描述
大家好,我想区分字段product_code
,我想显示所有字段表事务:
---------------------------------------------------
| id | product_code | price | datetime |
---------------------------------------------------
| 1 | 001 |20 | 2018-18-12 09:09:09 |
| 2 | 002 |30 | 2018-18-12 08:09:09 |
| 3 | 001 |20 | 2018-18-12 08:08:08 |
---------------------------------------------------
这是我的模型:
$this->db->distinct('product_code');
$this->db->select('id','product_code','price','datetime');
$this->db->from($this->table);
return $this->db->get()->result_array();
解决方案
您可以为您的问题尝试此解决方案:
$this->db->distinct();
$this->db->select('id','product_code','price','datetime');
$this->db->from($this->table);
return $this->db->get()->result_array();
比
echo $query->num_rows();
或者
$this->db->select('DISTINCT(product_code), ');
$this->db->from($this->table);
$query=$this->db->get();
print_r($this->db->get()->result_array());
echo $query->num_rows();exit;
我希望它会帮助你。
推荐阅读
- ios - 在 iOS 应用上使用 ESC/POS 命令打印二维码
- go - 无法导入 fyne.io/fyne/v2/app(不需要模块提供包“fyne.io/fyne/v2/app”)
- c - 显示字母问题的出现次数
- c - 循环期间在数组中覆盖的值
- java - HttpURLConnection 永远在 MacBook Pro M1 上的 android studio 中运行
- appium - 为什么Appium无法在android中启动应用程序
- c++ - 输入数组时,数组的长度替换C++中数组中的第一个元素
- css - 如何在 JavaFx TableView 中添加 TableView 页脚
- ssas - MDX:向度量添加条件
- angular - 使用 Angular 多出口