|
|
@@ -3,7 +3,6 @@
|
|
|
namespace App\Controller;
|
|
|
|
|
|
use Doctrine\DBAL\Connection;
|
|
|
-use Doctrine\DBAL\FetchMode;
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
|
@@ -22,8 +21,7 @@ class DbRawController
|
|
|
|
|
|
public function db(): JsonResponse
|
|
|
{
|
|
|
- $statement = $this->connection->prepare('SELECT id,randomNumber FROM World WHERE id = ?');
|
|
|
- $world = $statement->execute([mt_rand(1, 10000)]);
|
|
|
+ $world = $this->connection->executeQuery('SELECT id,randomNumber FROM World WHERE id = ?', [mt_rand(1, 10000)]);
|
|
|
|
|
|
return new JsonResponse($world->fetchAssociative());
|
|
|
}
|
|
|
@@ -40,7 +38,8 @@ class DbRawController
|
|
|
|
|
|
$statement = $this->connection->prepare('SELECT id,randomNumber FROM World WHERE id = ?');
|
|
|
for ($i = 0; $i < $queries; ++$i) {
|
|
|
- $world = $statement->execute([mt_rand(1, 10000)]);
|
|
|
+ $statement->bindValue(1, mt_rand(1, 10000));
|
|
|
+ $world = $statement->executeQuery();
|
|
|
$worlds[] = $world->fetchAssociative();
|
|
|
}
|
|
|
|
|
|
@@ -61,11 +60,12 @@ class DbRawController
|
|
|
|
|
|
for ($i = 0; $i < $queries; ++$i) {
|
|
|
$id = mt_rand(1, 10000);
|
|
|
- $world = $readStatement->execute([$id]);
|
|
|
- $world = $world->fetchAssociative();
|
|
|
- $writeStatement->execute(
|
|
|
- [$world['randomNumber'] = mt_rand(1, 10000), $id]
|
|
|
- );
|
|
|
+ $readStatement->bindValue(1, $id);
|
|
|
+ $world = $readStatement->executeQuery();
|
|
|
+ $world = $world->fetchAssociative();
|
|
|
+ $writeStatement->bindValue(1, mt_rand(1, 10000));
|
|
|
+ $writeStatement->bindValue(2, $id);
|
|
|
+ $writeStatement->executeStatement();
|
|
|
$worlds[] = $world;
|
|
|
}
|
|
|
|