我有一个带有 uniqueID/PrimaryKe (OrderNumber) 的数据库记录
我想用相同的 PrimaryKey OrderNumber 的新数据更新记录。
我的控制器是:
$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);
我的模型是:
function update_order_data($q){
$this->db->where('CustomerOrderID', 'OrderNumber'); //ordernumber being post input ordernumber in array
$query = $this->db->update('Customer_Order_Summary');
}
所以我想要的是:
update 'Customer_Order_Summary'
set 'CustomerName'="$this->input->post('customer')",
set 'CustomerAccountCode'="$this->input->post('accountcode')",
//rest of set statements for each column and corresponding post
where 'CustomerOrderID'='OrderNumberInArray'//(post value)
此更新声明不起作用,任何指针将不胜感激。
一如既往地感谢,