From 501da35c7aea416a73a896dcf494f1b7a75294ca Mon Sep 17 00:00:00 2001 From: Marvin Muxfeld Date: Tue, 3 Sep 2024 14:16:40 +0200 Subject: [PATCH] PISHPS-304: refactored Migration1725347559MollieTags::createTag it no longer uses the queryBuilder --- .../Migration1725347559MollieTags.php | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/src/Migration/Migration1725347559MollieTags.php b/src/Migration/Migration1725347559MollieTags.php index d59bd7f33..1450f70fb 100644 --- a/src/Migration/Migration1725347559MollieTags.php +++ b/src/Migration/Migration1725347559MollieTags.php @@ -44,32 +44,21 @@ private function createTag( string $id, string $name ): void { - // Create a new QueryBuilder instance - $queryBuilder = $connection->createQueryBuilder(); + $query = <<insert('tag') - ->values([ - 'id' => ':id', - 'name' => ':name', - 'created_at' => ':created_at', - 'updated_at' => ':updated_at', - ]) - ->setParameters([ - 'id' => Uuid::fromHexToBytes($id), - 'name' => $name, - 'created_at' => (new \DateTime())->format('Y-m-d H:i:s'), // current timestamp - 'updated_at' => null, - ]); + $stmt = $connection->prepare($query); - if (method_exists($queryBuilder, 'executeStatement')) { - // Execute the query (Shopware >= 6.4) - $queryBuilder->executeStatement(); - return; - } + $parameters = [ + 'id' => Uuid::fromHexToBytes($id), + 'name' => $name, + 'created_at' => (new \DateTime())->format('Y-m-d H:i:s'), + 'updated_at' => null, + ]; - // Execute the query (Shopware < 6.4) - $queryBuilder->execute(); + $stmt->execute($parameters); } }