How to implement server redirection during upgrade in mysql database?

The situation that I encountered is:

I have a php + mysql web application. several users share resources in one database. I want to implement a function that whenever there is a change in the records in the database (create, update or delete), other users will be notified instantly.

I am considering using ajax push engine (APE), but I don’t know what the big photo looks like.

(1) is it something like I need a script to constantly check last_update timestamps and send notifications to the client when a new change is detected?

OR

(2) every time after performing any operation on the database table, send a notification to clients telling them to reload the data?

which one is better or any other suggestions on how to implement this?

early!

+3
source share
2 answers

Your best option is No. 2, when you write to the database, when your change occurs, that is, when you must click.

class DatabaseModel
{
    ...

    function save($data)
    {
        ... // your db query

        after_save();
    }

    function after_save()
    {
        // push changes out using some other object 
        // e.g. MyPushClass::something_changed($this);
    }
}
+2
source

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


All Articles