Skip to content

Commit 94b283a

Browse files
committed
Fix database table loop
1 parent a5896a4 commit 94b283a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Traits/DatabaseTestTrait.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ protected function dropTables(): void
128128
WHERE table_schema = database()'
129129
);
130130

131+
$rows = (array)$statement->fetchAll(PDO::FETCH_ASSOC);
132+
131133
$sql = [];
132-
while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
134+
foreach ($rows as $row) {
133135
$sql[] = sprintf('DROP TABLE `%s`;', $row['TABLE_NAME']);
134136
}
135137

@@ -202,8 +204,10 @@ protected function truncateTables(): void
202204
AND update_time IS NOT NULL'
203205
);
204206

207+
$rows = (array)$statement->fetchAll(PDO::FETCH_ASSOC);
208+
205209
$sql = [];
206-
while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
210+
foreach ($rows as $row) {
207211
$sql[] = sprintf('TRUNCATE TABLE `%s`;', $row['TABLE_NAME']);
208212
}
209213

0 commit comments

Comments
 (0)