Skip to content

Commit

Permalink
PISHPS-304: refactored Migration1725347559MollieTags::createTag it no…
Browse files Browse the repository at this point in the history
… longer uses the queryBuilder
  • Loading branch information
m-muxfeld-diw committed Sep 3, 2024
1 parent 92d3494 commit 501da35
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions src/Migration/Migration1725347559MollieTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,21 @@ private function createTag(
string $id,
string $name
): void {
// Create a new QueryBuilder instance
$queryBuilder = $connection->createQueryBuilder();
$query = <<<SQL
INSERT INTO tag
(id, name, created_at, updated_at)
VALUES (:id, :name, :created_at, :updated_at)
SQL;

// Build the INSERT query
$queryBuilder
->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);
}
}

0 comments on commit 501da35

Please sign in to comment.