Is MySQL commit synchronous when executed from PHP PDO?

做~自己de王妃 提交于 2019-12-07 18:47:49

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!