如何在不同的 codeigniter 中显示文件
How to show filed in distinct codeigniter
大家好,我想区分字段 product_code
,我想显示所有字段
Table 交易:
---------------------------------------------------
| 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;
希望对你有所帮助
大家好,我想区分字段 product_code
,我想显示所有字段
Table 交易:
---------------------------------------------------
| 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;
希望对你有所帮助