<?php
$databases = $app->getContainer()->get('databases');
foreach ($databases as $name => $settings) {
  switch($settings->system) {
    case 'mysql':
      $dsn = implode(':', [
        'mysql',
        implode(';', [
          implode('=', [
            'host',
            $settings->host->name
          ]),
          implode('=', [
            'dbname',
            $settings->name
          ])
        ])
      ]);
      if (isset($settings->host->port)) {
        $dsn .= ';' . implode('=', [
          'port',
          $settings->host->port
        ]);
      }
      break;
  }
  ORM::configure($dsn, null, $name);
  switch ($settings->system) {
    case 'mysql':
      ORM::configure('username', $settings->user->name, $name);
      ORM::configure('password', $settings->user->password, $name);
  }
}
if (isset($databases->short_names)) {
  Model::$short_table_names = $databases->short_names;
}
