Issue
What i am trying to do:
Try to Clone Data (Update) from Table "Payment History" to "Payment" , But the problem right now is that in when i only select('Payment_Amount'), it works(update) but not everything , any idea ?
Payment Table
Payment_ID
Payment_Amount
Payment_Method
Payment_Remark
Payment History Table
Payment_ID
PaymentHistory_ID
Payment_Amount
Payment_Method
Payment_Remark
Both have the same column and same data type
My Code: Controller
public function updateHistory($Payment_ID){
// with single Payment_ID
//get data with specific column and ignore PaymentHistory_ID
$query = $this->db->select('Payment_Amount','Payment_Method','Payment_Remark')->where('Payment_ID', $Payment_ID)->get('YOUR FROM TABLE');
$result = $query->row_array();
if($result)
{ // check if has data
//then update to another table
$this->db->where('Payment_ID', $Payment_ID)->update('YOUR TO TABLE', $result ); // To update existing record
}
}
Based on the question that I have provided Codeigniter - Clone Data (But remove 1 column that is not exist ) , the codes works , but not the new problem that I am facing.
Note: New to CodeIgniter
Solution
if(!empty($result)) {
$this->db->where('Payment_ID', $Payment_ID)->update('YOUR TO TABLE', $result[0]); // To update existing record
}
Answered By - Tabrosh Shaikh
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.