0.1.0
This commit is contained in:
@ -49,5 +49,7 @@ if (file_exists($folder)) {
|
||||
|
||||
$app->addRoutingMiddleware();
|
||||
|
||||
include_once 'databases.php';
|
||||
//include_once 'databases.php';
|
||||
include_once 'router.php';
|
||||
|
||||
return $app;
|
||||
|
@ -5,7 +5,7 @@ foreach ($database->databases as $name => $settings) {
|
||||
switch (strtolower($settings->engine)) {
|
||||
case 'mysql':
|
||||
$dsn = "mysql:host={$settings->host->name};dbname={$settings->name}" . (isset($settings->host->port) ? ';port=' . $settings->host->port : '');
|
||||
ORM::configure([
|
||||
Orm::configure([
|
||||
'connection_string' => $dsn,
|
||||
'username' => $settings->user->name,
|
||||
'password' => $settings->user->password
|
||||
@ -13,12 +13,12 @@ foreach ($database->databases as $name => $settings) {
|
||||
break;
|
||||
}
|
||||
if (isset($settings->logging) and $settings->logging) {
|
||||
ORM::configure('logging', true, $name);
|
||||
Orm::configure('logging', true, $name);
|
||||
}
|
||||
if (isset($settings->caching) and $settings->caching) {
|
||||
ORM::configure('caching', true, $name);
|
||||
Orm::configure('caching', true, $name);
|
||||
}
|
||||
}
|
||||
if (isset($database->short_names) and $database->short_names) {
|
||||
Model::$short_table_names = true;
|
||||
Orm::$short_table_names = true;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ return [
|
||||
$arr = [
|
||||
'default' => (object) [
|
||||
'engine' => 'mysql',
|
||||
'driver' => 'pdo_mysql',
|
||||
'host' => (object) [
|
||||
'name' => $_ENV['MYSQL_HOST'] ?? 'db'
|
||||
],
|
||||
|
19
setup/setups/03_database.php
Normal file
19
setup/setups/03_database.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
return [
|
||||
\Doctrine\DBAL\Connection::class => function(ContainerInterface $container) {
|
||||
$config = $container->get('database')->databases['default'];
|
||||
$conn = [
|
||||
'dbname' => $config->name,
|
||||
'user' => $config->user->name,
|
||||
'password' => $config->user->password,
|
||||
'host' => $config->host->name,
|
||||
'driver' => $config->driver
|
||||
];
|
||||
if (isset($config->host->port)) {
|
||||
$conn['port'] = $config->host->port;
|
||||
}
|
||||
return \Doctrine\DBAL\DriverManager::getConnection($conn);
|
||||
}
|
||||
];
|
Reference in New Issue
Block a user