Update table data within Codeigniter Controller / MySQL

16,929

Assuming you have established your database connection.

 $orderid = $id;

if($this->input->post("status")=="OK" && $this->input->post("step")=="Confirmation" && $this->input->post("orderhash")==$orderHashOrg)
{

$updateData=array("status"=>"Paid");

$this->db->where("orderid",$orderid);
$this->db->update("orders",$updateData);    
}
Share:
16,929
Jack Johnson
Author by

Jack Johnson

Updated on June 04, 2022

Comments

  • Jack Johnson
    Jack Johnson almost 2 years

    I'm in a small pickle on this one. I'm using Codeigniter controller.

    I need to update an Order status where "DATA HERE" is located in the code below.

    Basically here is what i need to do locate the $orderid within a table called "orders" find the "status" and update it to the text "Paid".

    $orderid = $id;
    
    if($this->input->post("status")=="OK" && $this->input->post("step")=="Confirmation" && $this->input->post("orderhash")==$orderHashOrg)
        {
            // DATA HERE    
        }
    

    Any help is greatly appreciated.

    Here is my current code

    $updateData=array("status"=>"Paid");
    
        if($this->input->post("status")=="OK" && $this->input->post("step")=="Confirmation" && $this->input->post("orderhash")==$orderHashOrg)
        {
    
            $d = $this->db->get('offers_orders');
            $this->db->select('status');
            $this->db->where('order_number', $id);
    
            $orderdata = $d->result_array();
    
            $this->db->update("offers_orders", $updateData);
    
        }