Skip to content

Commit

Permalink
Fix database table loop
Browse files Browse the repository at this point in the history
  • Loading branch information
odan committed Feb 4, 2022
1 parent a5896a4 commit 94b283a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Traits/DatabaseTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ protected function dropTables(): void
WHERE table_schema = database()'
);

$rows = (array)$statement->fetchAll(PDO::FETCH_ASSOC);

$sql = [];
while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
foreach ($rows as $row) {
$sql[] = sprintf('DROP TABLE `%s`;', $row['TABLE_NAME']);
}

Expand Down Expand Up @@ -202,8 +204,10 @@ protected function truncateTables(): void
AND update_time IS NOT NULL'
);

$rows = (array)$statement->fetchAll(PDO::FETCH_ASSOC);

$sql = [];
while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
foreach ($rows as $row) {
$sql[] = sprintf('TRUNCATE TABLE `%s`;', $row['TABLE_NAME']);
}

Expand Down

0 comments on commit 94b283a

Please sign in to comment.