Backup.php 538 B

12345678910111213141516171819202122232425
  1. <?php
  2. // Start database connection
  3. $db = new \Micro\Database(config()->database);
  4. // Connect to databse server
  5. $db->connect();
  6. // Set name of migration object
  7. $migration = '\Micro\Migration\\' . ($db->type == 'mysql' ? 'MySQL' : 'PGSQL');
  8. // Create migration object
  9. $migration = new $migration;
  10. // Set database connection
  11. $migration->db = $db;
  12. // Set the database name
  13. $migration->name = 'default';
  14. // Load table configuration
  15. $migration->tables = config('Migration');
  16. // Backup existing database table
  17. $migration->backup_data();