这是我在avasam上的模型代码:
$this->db->select('*,orders.id AS order_id');
$this->db->from('orders');
$this->db->where('orders.user_id',$userId);
$this->db->join('products', 'products.id = orders.product_id');
$this->db->join('payments', 'payments.user_id = orders.user_id');
return $this->db->get();
result array
我为所有原始数据重复!
这是我db query
的分析器:
0.0004 SELECT *, `orders`.`id` AS `order_id`
FROM `orders`
JOIN `products` ON `products`.`id` = `orders`.`product_id`
JOIN `payments` ON `payments`.`user_id` = `orders`.`user_id`
WHERE `orders`.`user_id` = '24'
现在我不需要重复的数据。 我错了什么?
仅添加以下内容来解决:
$this->db->group_by('order_id');
未知原因$this->db->distinct();
未被唤醒