database - codeigniter update table row with new data array where -


i have database record uniqueid/primaryke (ordernumber)

i want update record new data same primarykey, ordernumber.

my controller is:

 $data = array(       'customername' =>  $this->input->post('customer'),       'customeraccountcode' =>  $this->input->post('accountcode'),       'periodstart' =>  substr($this->input->post('period'), 0,10),       'orderunitofmeasure' =>  $this->input->post('buom'),       'creditlimit' =>  $this->input->post('creditlimit'),       'balancebeforeorder' =>  $this->input->post('currentbalance'),       'balanceafterorder' =>  $this->input->post('newbalance'),       'orderlines' =>  $this->input->post('orderlines'),       'totalcost' =>  $this->input->post('grandtotal'),       'averagediscount' =>  $this->input->post('avediscount'),       'totalcubes' =>  $this->input->post('grandtotalcubes'),       'treatedcubes' =>  $this->input->post('grandtotaltreatedcubes'),       'specialcomments' =>  $this->input->post('specialcomments'),       'customerreference' =>  $this->input->post('customerref'),       'ordernumber' =>  $this->input->post('ordernumber')       );      $this->sales_model->update_order_data($data); 

my model is:

function update_order_data($q){     $this->db->where('customerorderid', 'ordernumber'); //ordernumber being post input ordernumber in array     $query = $this->db->update('customer_order_summary'); } 

so want :

update 'customer_order_summary'  set 'customername'="$this->input->post('customer')", set 'customeraccountcode'="$this->input->post('accountcode')", //rest of set statements each column , corresponding post 'customerorderid'='ordernumberinarray'//(post value) 

this update statement not working, pointers appreciated.

thanks always,

remove 'ordernumber' $data array , pass separately

$this->sales_model->update_order_data($this->input->post('ordernumber'),$data);‌ 

the query should like

function update_order_data($key,$q){  $this->db->where('customerorderid', $key);  $query = $this->db->update('customer_order_summary',$q); } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -