Trying to check values in another table before updating - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Trying to check values in another table before updating (/showthread.php?tid=63664) |
Trying to check values in another table before updating - alexandervj - 11-24-2015 I have a table in my database for Parts, and a table for a history of changes made to Parts. The fields in the parts table are in the $data array below and the fields in the history table are named the same as in the parts table but with a '_history' suffix. I'm trying to make it so that when someone edits the Part (running the update_part_details() function) then the values get checked against what is in the history table and if it is different then it adds the value to the history table - that way specific fields the history table only gets updated if a change has been made to those corresponding fields. However my code below is not working. I keep getting the errors - Undefinded Variable: data2 and further down i get another error that says 'You must use the "set" method to update an entry' I think my problem is in my array variable(s) here is my controller... Code: public function update_part_details(){ and here is my model Code: public function update_part_history_data($data) { Thanks for you help! RE: Trying to check values in another table before updating - solidcodes - 11-24-2015 try defining variable data2 first. $data2 = array(); |