jamband\schemadump\SchemaDumpController::actionDrop PHP Method

actionDrop() public method

Generates the 'dropTable' code.
public actionDrop ( string $schema = '' ) : integer
$schema string the schema of the tables. Defaults to empty string, meaning the current or default schema name.
return integer the status of the action execution
    public function actionDrop($schema = '')
    {
        $stdout = '';
        foreach ($this->db->schema->getTableSchemas($schema) as $table) {
            if ($table->name === $this->migrationTable) {
                continue;
            }
            $stdout .= "\$this->dropTable('{{%{$table->name}}}');";
            if (!empty($table->foreignKeys)) {
                $stdout .= " // fk: ";
                foreach ($table->foreignKeys as $fk) {
                    foreach ($fk as $k => $v) {
                        if ($k === 0) {
                            continue;
                        }
                        $stdout .= "{$k}, ";
                    }
                }
                $stdout = rtrim($stdout, ', ');
            }
            $stdout .= "\n";
        }
        $this->stdout($stdout);
    }