Reputation: 1360
This is my Model codes on 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();
in result array
i have duplicate for all raw !
and this is my profiler for 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'
Now i don't need duplicate data's . what's my wrong ?
Upvotes: 0
Views: 355
Reputation: 1360
solve by adding only this :
$this->db->group_by('order_id');
For unknown reasons $this->db->distinct();
Not woked
Upvotes: 1