<?php
$databases = config('databases');

load($databases['mysql']);

foreach ($databases as $name => $data) {
	load($data, $name);
}

function load($data, $name = '') {
	if (!isset($data['port'])) {
		$port = 3306;
	} else {
		$port = $data['port'];
	}
	$dsn = 'mysql:host=' . $data['host'] . ';port=' . $port . ';dbname=' . $data['database'] . ';charset=utf8';

	if ($name != '') {
		ORM::configure($dsn, null, $name);
		ORM::configure('username', $data['username'], $name);
		ORM::configure('password', $data['password'], $name);
	} else {
		ORM::configure($dsn, null);
		ORM::configure('username', $data['username']);
		ORM::configure('password', $data['password']);
	}
}

Model::$short_table_names = true;
?>
