Using the PHP PDO interface to MySQL, suppose I have this code to end a transaction (assuming it was properly begun):
$pdo->query('commit');
When the function returns, have writes to the log been flushed? That is, is the transaction committed, or have I merely made a request that it be committed? Assuming that I have not set any options to delay flushing, such as, for example, setting innodb_flush_log_at_trx_commit to zero.
I ask because, if I were to follow the code above with this:
echo 'Transaction has been committed.';
I wouldn't want to be caught in a lie.
UPDATE: See the comments below. I'm not asking how InnoDB works. I'm asking whether the PDO interface waits for the InnoDB engine to execute the command before returning.
UPDATE #2: I should have said that the commit would be performed by a call to PDO::commit, which is how I actually do it, in case there's any difference between that and doing it with SQL.
来源:https://stackoverflow.com/questions/16466753/is-mysql-commit-synchronous-when-executed-from-php-pdo