DBI database handle with AutoCommit set to 0 not returning proper data with SELECT?

前端 未结 2 1674
迷失自我
迷失自我 2021-02-20 06:53

This is a tricky one to explain (and very weird), so bear with me. I will explain the problem, and the fix for it, but I would like to see if anyone can explain why it works the

2条回答
  •  甜味超标
    2021-02-20 07:13

    I think that when you turn autocommit off, you also start a transaction. And, when you start a transaction, you may be protected from other people's changes until you commit it, or roll it back. So, if my semi-informed guess is correct, and since you're only querying the data, add a rollback before the sleep operation (no point in holding locks that you aren't using, etc):

    $dbh->rollback;
    

提交回复
热议问题