Last active
October 1, 2023 18:53
-
-
Save mbischof/3049758 to your computer and use it in GitHub Desktop.
How to drop all tables from database using yii
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$tables = Yii::app()->db->schema->getTableNames(); | |
foreach ($tables as $table) { | |
Yii::app()->db->createCommand()->dropTable($table); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Neither one of your code should work. You need to add
->execute()
afterdropTable()
.Also,
app()
doesn't exist... It should be$app
.Fixed code below, or view my Fork of this Gist:
Hope it helps 👍