Answer the question
In order to leave comments, you need to log in
How to make "manual" analogue of a trigger on UPDATE in MySQL without using a trigger?
There is a need to find rows in a table that have changed certain fields.
The hoster does not support triggers, moving is not taken into account.
At first there was an idea to add boolean type fields and in scripts, in places where UPDATE occurs, add `label_field_what_field_changed` = 1
And after the change, it is used in third-party software and after checking it returns to 0.
But I thought that I could change it manually, for example in PHPMyAdmin, but I'll forget to put a label.
Then a variant was invented that the fields that need to be “monitored”, write the hash into a separate field, that is, `hash`=MD5(CONCAT(`field2`,`field3`,`field5`))
And before using it in third-party software, do a check to see if the hash has changed, and if it has changed, mark the fields or use them immediately, etc.
Fortunately, there are not very many ~ 5000 lines and, according to tests, the speed satisfies.
So far I have settled on this option, but maybe someone knows a better option?
Thank you!
Answer the question
In order to leave comments, you need to log in
It is also possible to use a TIMESTAMP field and ON UPDATE CURRENT_TIMESTAMP
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question