Welcome Guest, Not a member yet? Register   Sign In
How to remove duplicates in CodeIgniter query?

I am using CodeIgniter3 to place an order, and I need to display multiple rows of a specific order ID from the DWO_Panelplating table on an overview page. However, I am encountering an issue where I am getting a lot of duplicates (almost 2000 rows instead of 2) when I load my query in the view.


$data["panelplating"] = $this->Panelplating->read__entry($order_id);


public function read__entry($id) {
$this->db->select("p.id, p.created_on, p.modified_on, p.order_id as order_id, p.type, p.material as material, p.thickness, p.amount, p.length_a as length_a, p.length_b1, length_b2, p.length_c, p.length_d, p.width, p.paint, p.color, p.paintA1, p.paintA2, p.paintB11, p.paintB12, p.paintB21, p.paintB22, p.paintC1, p.paintC2, p.paintD1, p.paintD2, pt.thickness as thickness_size, pt.pricerange1 as price_small, pt.pricerange2 as price_medium, pt.pricerange3 as price_large, pt.pricerange4 as price_xlarge, pll.type as type, c.ral_code as colorcode, pm.material as type_material");
$this->db->from(join(" ", array(self::TABLE_NAME, self::TABLE_SHORT)));
$this->db->join("DWO_Orders o", "p.order_id = o.id", "LEFT");
$this->db->join("DWO_Platingamounts pl", "p.order_id = pl.order_id", "LEFT");
$this->db->join("DWO_Platingamounts pll", "p.type = pll.type", "LEFT");
$this->db->join("DWO_Platethicknesses pt", "p.thickness = pt.id", "LEFT");
$this->db->join("DWO_Platingmaterials pm", "p.material = pm.id", "LEFT");
$this->db->join("DWO_Colors c", "p.color = c.id", "LEFT");
$this->db->where("p.order_id", $id);
return $this->db->get()->result();


<label for="plating" class="block text-sm font-medium text-gray-700 sm:mt-px sm:pt-2">
    <?php foreach ($panelplating as $plating):?>
        <?= $plating->id?>
    <?php endforeach?>
I need suggestions or solutions to fix this issue. Thank you in advance!

Theme © iAndrew 2016 - Forum software by © MyBB