Tell me, please, will the data be entered into the database only when the connection is closed or not?
6 answers
NOT!!! When do requests.
Open connection
$link = mysql_connect($host, $dbuser, $dbpass); mysql_select_db($db, $link);
Make a request
$sql="INSERT INTO mybesttable (f1,f2) VALUES('f1val','f2val')"; mysql_query($sql);
Definitely not. An example from real life: "Is it possible to get a bucket of water from a tap if it is closed and does not flow?"
Either immediately after INSERT requests or after completion of transactions in which INSERTs are present.
The data in the database will be entered in the case of a successful query (TRUE) mysql_query () . In case of error, FALSE will be returned.
Interest Ask. It can not give a definite answer, not knowing all the specifics of hardware and software.
For example, data, such as those written to disk, can be cached in the operating system's buffer. That is, the connection is already closed, the DBMS reported that the data was recorded, but in fact there is no data on the disk yet - they are in the buffer. And with a sudden power outage they will disappear.
Of course, this behavior is not all drives. However, servers should use certified equipment, the manufacturer of which guarantees the availability of the possibility of forced flushing of buffers to disk.