php - Function to revert mysql statement -


how can implement undo changes function in php application, if user example added new member group, or deleted item notification message appear: selected item have been deleted, undo delete action(link trigger undo function).

the following working code:

public function deleterecord($id) {             $group = $this->query('set autocommit=0');             $group = $this->query('delete  `members` memberid = '.$id.'');      }       public function undo_delete() {             $member = $this->query('rollback');     if($member) {             trigger_error('undo action has been completed. ', e_user_notice);             return true; }      } 

the problem code transaction has not been submitted, rollback or log out undo changes has been done during user session, not sure if best approach create redo function, suggestions?

you not able undo 2 different requests .because when call undo . undo delete happened members . solve suggest -

  1. you create new table keep information of deleted record, eg- deleted_members.
  2. when user calls undo fetch data deleted_members table , insert original members table.
  3. after successful insert in original table ,remove data delete information table.

i hope helped.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -