Good morning, I would like to know if PHP prepare statement is synchronous or asynchronous, for example :
$req1 = "UPDATE ...";
$statement1 = $connection->prepare($req1);
$statement1->execute();
$req2 = "SELECT ...";
$statement2 = $connection->prepare($req2);
$statement2->execute();
So the result of the second request depend on the first, it may cause problems or wrong results, in others words, there's a possibility that the second request execute before the first.
I searched for answers, but i haven't found a clear answer. Thanks you.
Database queries are executed synchronously. But don't take my word for it, check the manual:
PDO: http://php.net/manual/en/pdostatement.execute.php
Since the method result is TRUE on success or FALSE on failure you can deduce it is synchronous.
MySQLi: http://php.net/manual/en/mysqli-stmt.execute.php
Same here. So check the documentation and if the execute() returns something related to the result you know it has to be synchronous.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With