Skip to content

Commit

Permalink
Set default dsn to current folder.
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxd committed Aug 14, 2017
1 parent 8bf63fe commit e2a0555
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/app/cmd/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ class Base
public function __construct()
{
$aConfig = c\Config::get('dsn');
u\DB::connect($aConfig['data']);

if ($aConfig['result']) {
u\DB::connect($aConfig['data']);
} else {
$tmp = str_replace('phar://', 'sqlite:', __DIR__);
$dsn = str_replace('opensesame.phar/app/cmd', '084', $tmp);
u\DB::connect($dsn);
}

$aConfigKey = c\Config::get('secret_key');
m\Account::$sSecretKey = $aConfigKey['data'];
Expand Down
9 changes: 8 additions & 1 deletion src/app/controller/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ class Base extends c\Controller
public function handle()
{
$aConfig = c\Config::get('dsn');
u\DB::connect($aConfig['data']);

if ($aConfig['result']) {
u\DB::connect($aConfig['data']);
} else {
$tmp = str_replace('phar://', 'sqlite:', __DIR__);
$dsn = str_replace('opensesame.phar/app/controller', '084', $tmp);
u\DB::connect($dsn);
}

$aConfigKey = c\Config::get('secret_key');
m\Account::$sSecretKey = $aConfigKey['data'];
Expand Down

0 comments on commit e2a0555

Please sign in to comment.