teach me
teach me

Reputation: 485

php server-side application misunderstanding

to explain my misunderstanding I'll give an example:

If 2 different users are viewing the same database table (within their browsers) and one of the user alter the table I would like the other user to see the changes immediately.

If I would do it with C++ I would create observer pattern and notify all the registered observers (users) that the subject (database table) changed. I'll do it by calling the notify method right after I alter the table. I can do this because all the users interact with the same instance of my application (there will be only one application instance at the server).

I know that I can create observer pattern also with PHP quit easily. But what I don't understand is how PHP application behave, will my application have different instance for each user? how can I solve the above example?

What am I missing here?

Any answer, article, link to relevant info will be much appreciated.

Upvotes: 0

Views: 65

Answers (1)

dcro
dcro

Reputation: 13679

You need to do more research on this to understand the basic concept of how web applications work in general, and PHP apps in particular, but the short version is that you need to push a notification to the client's browser when something changes, so it can update the UI.

You can either use a paid service like Pusher or come up with your own implementation based on Websockets or long polling.

Upvotes: 1

Related Questions