问题
I've a comet there I run an while loop in this way
$items = $statement->fetchAll();//statement is a PDO Statement
$iteration = 0;
while(count($items) == 0 && $iteration < 100){
$items = $statement->fetchAll();
usleep(10000);
++$iteration;
}
When the comet runs I can see all other HTTP requests are pending. even non-database requests are pending. Why ?
回答1:
You need to manually commit using PDO::commit
as the request are being hold in a transaction.
Please see the docs about this behavior:
http://www.php.net/manual/de/pdo.commit.php
http://www.php.net/manual/en/pdo.transactions.php
来源:https://stackoverflow.com/questions/11126465/php-comet-usleep-blocking-apache-mpm