Getting the difference in MySQL database

I have a mysql database. What I would like to do is perform an arbitrary action on it and then figure out what has changed. Something like that:

//assume connection to db already established

before();//saves db state
perform_action();//does stuff to db
diff();//prints what happened

I want it to output something like:

Row added in table_0 ]details]
Row added in table_1 [details]
Row modified in table_5 [details]
Row deleted in table_2 [details]

Any ideas?


Further clarification: do you know how in stackoverflow, if you check for changes after posting, you can see red lines / green highlights that indicate what was changed? I want something similar, but for mysql databases.

+3
source share
4 answers

I think that usually your application logs any interesting changes, as it makes them. Or you would set up history tables for everything with datetimes.

, , diff . php xdiff: http://us.php.net/manual/en/book.xdiff.php

, , , , .

+1
+4

- , SQL, . , SQL-, ( )

0

, , :

  • [?] , . , , , .

  • , ; grab rows, , .

  • ( - $db->query(), ), , .

, , , , , , .

0

Source: https://habr.com/ru/post/1752842/


All Articles