Exemple #1
0
<?php

use BZIon\Composer\ScriptHandler;
require "vendor/autoload.php";
$config = ScriptHandler::getDatabaseConfig();
$testConfig = ScriptHandler::getDatabaseConfig(true);
return array('paths' => array('migrations' => __DIR__ . '/migrations'), 'environments' => array('default_migration_table' => 'migration_log', 'default_database' => 'main', 'main' => array('adapter' => 'mysql', 'host' => $config['host'], 'name' => $config['database'], 'user' => $config['username'], 'pass' => $config['password']), 'test' => $testConfig ? array('adapter' => 'mysql', 'host' => $testConfig['host'], 'name' => $testConfig['database'], 'user' => $testConfig['username'], 'pass' => $testConfig['password']) : null));
Exemple #2
0
 /**
  * @Given that the database is empty
  */
 public static function clearDatabase()
 {
     $db = Database::getInstance();
     // Get an array of the tables in the database, so that we can remove them
     $tables = array_map(function ($val) {
         return current($val);
     }, $db->query('SHOW TABLES'));
     if (count($tables) > 0) {
         $db->execute('SET foreign_key_checks = 0');
         $db->execute('DROP TABLES ' . implode($tables, ','));
         $db->execute('SET foreign_key_checks = 1');
     }
     ScriptHandler::migrateDatabase(null, true);
     if ($modelCache = Service::getModelCache()) {
         $modelCache->clear();
     }
 }