如何在不同的codeigniter中显示文件

问题描述 投票:0回答:1

大家好我想要明确字段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();
distinct codeigniter-3
1个回答
0
投票

你可以尝试这个解决方案的问题:

$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;

我希望它会对你有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.