1

I getting Unknown column 'Array' in 'field list' error

i like to do is what ever random numeric inserted to invoice column i should pass it to the column transaction_num of another table.

MY CONTROLLER

$order = array(
           'date' => $date,
           'customer_id' => $cust_id,
           'invoice' => random_string('numeric', 6)
           );
    $ord_id = $this->PaymentModel->insert_order($order);

    $invoice = $this->PaymentModel->get_invoice($ord_id);

$order_detail = array(
        'transaction_num' => $invoice,

//there is other data to be inserted here i just removed it coz this column is the only problem
                );
$this->PaymentModel->insert_order_detail($order_detail);

MY PAYMENT MODEL

public function get_invoice($ord_id){

        $query = $this->db->select('invoice')->from('orders')->where('serial', $ord_id)->get(); 
        return $query->result_array();


}
public function insert_order_detail($order_detail) {
    $this->db->insert('order_detail', $order_detail);

}
rinru
  • 141
  • 4
  • 19

1 Answers1

0

just change

public function get_invoice($ord_id){

        $query = $this->db->select('invoice')->from('orders')->where('serial', $ord_id)->get(); 
        return $query->result_array();


}

to

   public function get_invoice($ord_id){

            $this->db->where('serial', $ord_id);
            $query = $this->db->get('invoice')->row_array(); 
            return $query['invoice'];


    }

/////////////////////////////or//////////////////////

I am assuming you are doing above functionality in same function.So, you can just store

$invoice=random_string('numeric', 6);

and supply this to both tables

mokNathal
  • 533
  • 1
  • 6
  • 20