From the manual it says FLUSH TABLES:
Closes all open tables, forces all tables in use to be closed, and
flushes the query cache. FLUSH TABLES also removes all query results
from the query cache, like the RESET QUERY CACHE statement.
I don’t quite understand from the above, what is the implication it has when a FLUSH TABLES is performed while a PHP script consisting of several queries is run. Suppose that I have an UPDATE query on TABLE A, followed by an INSERT query on TABLE B, followed by mail() and header() on a transaction page, would the INSERT query be deleted when FLUSH TABLES is performed while MySQL is running the UPDATE query?
MySQL will wait until the end of queries made before, and then it will execute FLUSH TABLES. The queries made after FLUSH TABLES will be enqueued and executed after FLUSH TABLES.
If nothing unusual happen, no queries will be lost.