title: codeigniter update table row with new data array where
body: <p>I have a database record with a uniqueID/PrimaryKe (OrderNumber)</p>
  
  <p>I want to update the record with new data for that same PrimaryKey, OrderNumber.</p>
  
  <p>My Controller is:</p>
  
  <pre><code> $data = array(
        'CustomerName' =&gt;  $this-&gt;input-&gt;post('customer'),
        'CustomerAccountCode' =&gt;  $this-&gt;input-&gt;post('accountcode'),
        'PeriodStart' =&gt;  substr($this-&gt;input-&gt;post('period'), 0,10),
        'OrderUnitOfMeasure' =&gt;  $this-&gt;input-&gt;post('buom'),
        'CreditLimit' =&gt;  $this-&gt;input-&gt;post('creditlimit'),
        'BalanceBeforeOrder' =&gt;  $this-&gt;input-&gt;post('currentbalance'),
        'BalanceAfterOrder' =&gt;  $this-&gt;input-&gt;post('newbalance'),
        'OrderLines' =&gt;  $this-&gt;input-&gt;post('orderlines'),
        'TotalCost' =&gt;  $this-&gt;input-&gt;post('grandtotal'),
        'AverageDiscount' =&gt;  $this-&gt;input-&gt;post('avediscount'),
        'TotalCubes' =&gt;  $this-&gt;input-&gt;post('grandtotalcubes'),
        'TreatedCubes' =&gt;  $this-&gt;input-&gt;post('grandtotaltreatedcubes'),
        'SpecialComments' =&gt;  $this-&gt;input-&gt;post('specialcomments'),
        'CustomerReference' =&gt;  $this-&gt;input-&gt;post('customerref'),
        'ordernumber' =&gt;  $this-&gt;input-&gt;post('ordernumber')
        );
  
      $this-&gt;sales_model-&gt;update_order_data($data);
  </code></pre>
  
  <p>My model is:</p>
  
  <pre><code>function update_order_data($q){
      $this-&gt;db-&gt;where('CustomerOrderID', 'OrderNumber'); //ordernumber being post input ordernumber in array
      $query = $this-&gt;db-&gt;update('Customer_Order_Summary');
  }
  </code></pre>
  
  <p>So what I want is :</p>
  
  <pre><code>update 'Customer_Order_Summary' 
  set 'CustomerName'="$this-&gt;input-&gt;post('customer')",
  set 'CustomerAccountCode'="$this-&gt;input-&gt;post('accountcode')",
  //rest of set statements for each column and corresponding post
  where 'CustomerOrderID'='OrderNumberInArray'//(post value)
  </code></pre>
  
  <p>This update statement is not working, any pointers would be appreciated.</p>
  
  <p>Thanks as always,</p>