立即可视化MySQL任务

I am using PHP + MySQL. I am inserting 20 Megs of 40000 items via Insert task each day into one data warehouse table. I need to see the immediate sql task in my PHP script (something like task ticker), but all the 'echos' are written only after the PHP script ends.

Is it possible without using AJAX ?

Or can you recommend me any solution for that ?

I need to show something like that: INSERT INTO table VALUES (1,2,3);

What you need to do is echo your $query each time just before you run it.

But I guess you already tried it and failed to see it work directly.

This could be because php or your web server is buffering the output until the entire request is complete.

You can do the following to prevent the buffering:

  • use flush() after the echo that needs to be echoed to directly
  • don't use ob_start() and turn on implicit flushing because even without ob_start php might to implicit buffering
  • don't use compression.

you can try to fiddle with these commands:

apache_setenv('no-gzip', 1);
ini_set('output_buffering', 0);
ini_set('zlib.output_compression', 0);
ini_set('implicit_flush', 1);