MySQL的PHP​​数据处理进展

I'm wondering what a concept is called...

When you process a data, such as adding something to a database, you get a real time view of what is being inserted in the database.

For example, if I upload the following employee data from Excel:

  • Brian
  • Elmer
  • Gomer

It would show something like this while processing:

Starting to add data..
Brian has been successfully added.
Processing bla bla
Elmer has been successfully added.
Process bla bla
Gomer failed to be added. see details.

What do you call this kind of function? Could someone describe a bit how to do this?

I'm not sure what you'd call this.

On the face of it you should be able to generate an output like this just by emitting a message at every point in the processing you wish. However, PHP, your web server, any intervening proxies and your browser can cache or buffer the messages you're sending like this such that nothing appears for a while, then every message appears at once.

Whilst it is sometimes possible to work around that by careful use of buffer flushing, it's fiddly and not necessarily reliable.

An alternative approach is to use Server Sent Events where the web page sets up an event handler to list for a particular stream of messages and displays each message as it arrives. This requires code at both the web page and the server to handle the message stream, but it bypasses the caching and buffering issue above.

You can find more details on Server Sent Events together with some sample code here