doushupu2521 2015-05-20 12:02
浏览 8
已采纳

在mysql中执行查询的PHP序列

If I have a bunch of queries(mysql) in PHP, assuming that i'm using PDO, these queries will be executed in sequence, but PHP or MySQL will wait one query to finish before start a new one?

$sql1 = $con->prepare("some query");
$sql2 = $con->prepare("some query");   
$sql3 = $con->prepare("some query");

$sql1->execute();
$sql2->execute();
$sql3->execute();

And if I use a transactional block in PDO with the same queries:

$con->beginTransaction();

Will the execution be the same?

  • 写回答

1条回答 默认 最新

  • dongxianglun5163 2015-05-20 12:06
    关注

    A query is a single SQL statement that does Select, Update, Insert or Delete of rows.

    A transaction is a consecutive sequence of SQL statements (from the application viewpoint) that have the "ACID" properties:

    • Atomicity: All statements or none are executed.
    • Consistency: Data integrity is always maintained.
    • Isolation: Transaction A can never affect Transaction B.
    • Durability: Changes that are committed by a transaction persist, even in event of system failure.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?