v0.1.0
This commit is contained in:
30
provm/common/Service/Database.php
Normal file
30
provm/common/Service/Database.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
namespace ProVM\Common\Service;
|
||||
|
||||
use \ORM;
|
||||
use \Model;
|
||||
use ProVM\Common\Service\Database\MySQL;
|
||||
|
||||
class Database {
|
||||
protected $settings;
|
||||
public function __construct($settings) {
|
||||
$this->settings = $settings;
|
||||
}
|
||||
public function load() {
|
||||
foreach ($this->settings->dbs as $name => $data) {
|
||||
switch (strtolower($data->engine)) {
|
||||
case 'mysql':
|
||||
$obj = new MySQL($data);
|
||||
break;
|
||||
}
|
||||
ORM::configure($obj->dsn(), null, $name);
|
||||
if ($obj->hasUser()) {
|
||||
ORM::configure('username', $data->user->name, $name);
|
||||
ORM::configure('password', $data->user->password, $name);
|
||||
}
|
||||
}
|
||||
if (isset($this->settings->short_names)) {
|
||||
Model::$short_table_names = $this->settings->short_names;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user