<?php
function loadDatabase(object $settings, string $name): void
{
    $port = 3306;
    if (isset($settings->port)) {
        $port = $settings->port;
    }
    $dsn = 'mysql:host=' . $settings->host . ';port=' . $port . ';dbname=' . $settings->database . ';charset=utf8';

    ORM::configure($dsn, null, $name);
    ORM::configure('username', $settings->username, $name);
    ORM::configure('password', $settings->password, $name);
}

$databases = $app->getContainer()->get('databases');
foreach ($databases as $name => $settings) {
    loadDatabase($settings, $name);
}

Model::$short_table_names = true;
