Q:

Update query in Codeigniter

I want to update the data into the database, and must match the two conditions then only will update the data in database.
Please take a look in my Model, there has two condition, which is id and order_id.
When only assign one condition[$this->db->where('order_id',$id);], it works well for one item, but when the order has two item and above, it only can update the data for last row of the order items.
So, I try with two condition, which is [$this->db->where('order_id',$id);] and [$this->db->where('id',$oid);], but it cannot works.
Updated!!
I had changed some codes in controller and model
I get an error:[Array to string conversion],id = Array AND order_id = '10'
Controller:
public function EditOrderPage(){
        $id = $this->uri->segment(3);
        $oid = $this->order->GetCusOrderItemID($id);

        $data['title']       = "JCUBE";
        $data['orders']      = $this->order->GetCusOrder($id);
        $data['orderitems']  = $this->order->GetCusOrderItem($id);
        $data['item']        = $this->order->GetItem();
        $data['projectcode'] = $this->order->GetProjectCode();
        $data['payoption']   = $this->order->GetPayOption();
        $data['eppmonth']    = $this->order->GetEppMonth();
        $this->load->view('ordering/header',$data);
        $this->load->view('ordering/edit_order_page',$data);
        $this->load->view('ordering/footer',$data);

        if($this->input->post('update')){ //if press button 'update order'
            $email       = $this->input->post('email');
            $tel         = $this->input->post('telno');
            $address     = $this->input->post('address');
            $projectCode = $this->input->post('projectcode');
            $payOption   = $this->input->post('options');
            $eppMonth    = $this->input->post('eppmonth');
            $RefOrderID  = $this->input->post('ref_order_id');
            $remark      = $this->input->post('remark');
            $grandTotal  = $this->input->post('grandtotal');
            $this->order->UpdateOrderHeader($email,$tel,$address,$projectCode,$payOption,$eppMonth,$RefOrderID,$remark,$grandTotal,$id);

            $post = $this->input->post();
            $arraySize = count($post['item_id']);       
            for($k=0; $k<$arraySize; $k++){
                $itemName = $this->order->GetItemName($post['item_id'][$k]);

                $productId       = $post['item_id'][$k];
                $itemName        = $itemName['item_name']; //to be search in model using productID
                $quantity        = $post['qty'][$k];
                $weight          = $post['weight'][$k];
                $transportation  = $post['transportation'][$k];
                $premium         = $post['gp'][$k];
                $discount        = $post['discount'][$k];
                $unitPrice       = $post['unit_price'][$k];
                $TotalWithoutTax = $post['totalwithouttax'][$k];
                $TotalTax        = $post['totaltax'][$k];
                $TotalAmtInclTax = $post['totalamtincltax'][$k];
                $this->order->UpdateOrderItems($productId,$itemName,$quantity,$weight,$transportation,$premium,$discount,$unitPrice,$TotalWithoutTax,$TotalTax,$TotalAmtInclTax,$oid,$id);

            }
        }
    }

Model:
public function GetCusOrderItemID($id = NULL){
      $this->db->select('oi.id',$id);
      $this->db->from('order_items oi');
      $this->db->join('order o', 'oi.order_id = o.id');
      $this->db->where('o.id');

      $query = $this->db->get();
      return $query->result_array();
    }

public function UpdateOrderItems($productId,$itemName,$quantity,$weight,$transportation,$premium,$discount,$unitPrice,$TotalWithoutTax,$TotalTax,$TotalAmtInclTax,$oid,$id){
   $OrderItem = array(
                              'product_id'            => $productId,
                              'item'                  => $itemName,
                              'qty'                   => $quantity,
                              'weight'                => $weight,
                              'transportation_price'  => $transportation,
                              'gp'                    => $premium,
                              'discount'              => $discount,
                              'unit_price'            => $unitPrice,
                              'amt_without_tax'       => $TotalWithoutTax,
                              'tax'                   => $TotalTax,
                              'amt_incl_tax'          => $TotalAmtInclTax
                           );
      $this->db->set($OrderItem);
      $this->db->where('id',$oid);
      $this->db->where('order_id',$id);
      $this->db->update('order_items');

View:
<?php
                foreach($orderitems as $orderitem) { ?>
                <tr class="item-details">
                    <td><input id="orderitems" type="hidden" class="form-control" name="id" value="<?=$orderitem['id']?>" readonly></td>
                    <td class="">
                            <?php
                            $options = array(
                                             '' => '~Choose An Item~'
                                             );
                            foreach ($item as $rows){
                                $options[$rows->id] = $rows->item_name;
                            }

                            $select = array(
                                            'name' => 'item',
                                            'id' => 'item_id',
                                            'class' => 'form-control'
                                            );
                            echo form_dropdown('item_id[]', $options,set_value('item_name',$orderitem['product_id']),$select);
                            ?>
                    </td>
                    <td class=""><input type="number" id="qty[]" class="item-qty" name="qty[]" step="1" min="0" value="<?=$orderitem['qty']?>"/></td>
                    <td><input type="number" name="weight[]" class="weight" step="any" value="<?=$orderitem['weight']?>"/></td>
                    <td><input type="number" name="transportation[]" class="transporation" step="any" value="<?=$orderitem['transportation_price']?>" readonly/></td>
                    <td><input type="text" id="gp[]"  name="gp[]" value="<?=$orderitem['gp']?>" /></td>
                    <td><input type="text" id="discount[]"  name="discount[]" value="<?=$orderitem['discount']?>" readonly/></td>
                    <td><input type="text" id="unit_price[]"  name="unit_price[]" value="<?=$orderitem['unit_price']?>" /></td>
                    <td align="right">
                        <input type="text" id="totalwithouttax[]" name="totalwithouttax[]" value="<?=$orderitem['amt_without_tax']?>" readonly>
                    </td>
                    <td align="right">
                        <input type="text" id="totaltax[]" name="totaltax[]" value="<?=$orderitem['tax']?>" readonly>
                    </td>
                    <td align="right">
                        <input type="text" id="totalamtincltax[]" name="totalamtincltax[]" value="<?=$orderitem['amt_incl_tax']?>" readonly>
                    </td>
                </tr><br/><br><br><br>
                <?php } ?>

I wish that I can update the items with these two condition. Hope someone can help me.

A:

Modify GetCusOrderItemID function like this :  
public function GetCusOrderItemID($id = NULL){
    $this->db->select('oi.id item_id');
    $this->db->from('order_items oi');
    $this->db->join('order o', 'oi.order_id = o.id');
    $this->db->where('o.id',$id);

    $query = $this->db->get();
    return $query->result_array();
}

And change $oid to $oid[$k]['item_id'] in :  
$this->order->UpdateOrderItems($productId,$itemName,$quantity,$weight,$transportation,$premium,$discount,$unitPrice,$TotalWithoutTax,$TotalTax,$TotalAmtInclTax,$oid[$k]['item_id'],$id);

