Closed mmoreram closed 4 years ago
seq([ $mysql->createTable(), $mysql->addElement(), $musql->findElement() ]) ->then(array $results) { $result[2]->getId(); });
Running that code will execute all 3 operations at the same time and not in sequence. Chaining them this way will execute them in sequence:
$mysql->createTable()->then(function () {
return $mysql->addElement();
})->then(function () {
return $musql->findElement();
})->then(array $results) {
$result[2]->getId();
});
Chaining them is what this method does internally. Am I missing something?
You're chaining the outcome in this method, not the execution. The moment you start an operation it will immediately start doing what you tell it to do. The promise is only a placeholder for the outcome of that operation.
Totally right :=(
The idea itself isn't perse bad FYI ;)
Is it correct having $mysql
and $musql
?
@markuszeller fixed. It was a typo
@markuszeller @mmoreram and I kept it in because it didn't matter for the example you where making :D
Executes each row of an array sequentially. Returns an array of each result.
This PR is not tested yet.