0
votes

I have a MsUser table consist of 4 fields i.e. Id, Name, Address, and date-of-birth. Every update process, one or more fields can be updated simultaneously. I want to track the change every update.

Example: the updated fields are address and date-of-birth. System will show "Address and date-of-birth are updated".

From that case, how should i build the edit function in model to track the updated field each update?

I have no idea how to check the changed fields from user's input. Because if i have to loop and check each field, i think it costs too much effort for the system process.

Thank you for your helps :)

1
when should system will show Address and date-of-birth are updated? any particular action? - Pathik Vejani
The system will show "Address and date-of-birth are updated" after the update process/button is clicked. - Hendra Halim
basically you have to check each string with previous string and then you have to display message. - Pathik Vejani
@PathikVejani here is my code in model for updating my msuser table. codepad.org/avU2JiOq - Hendra Halim
@PathikVejani So there is no other option except checking each field text by text? - Hendra Halim

1 Answers

0
votes

You have the $this->input->post() if I'm not mistaken. If you foreach the post and check each key of the array which has a value you can see what has been changed. Small idea of achieving this would be:

$count = 0;
foreach($this->input->post() as $field){
    if(count($this->input->post()) == $count):
        $updatedFields .= $field.", ";
    else:
        $updatedFields .= $field;
    endif;
    $count++;
}
$updatedFields .= " have been updated.";
echo $updatedFields;

This would output:

username, date-of-birth have been updated.