Skip to content

Commit

Permalink
fix: patch up config inconsistency
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Aug 23, 2024
1 parent 3fd8d2d commit 068de19
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Db/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function __construct(
string $dbtype = 'mysql'
) {
if (class_exists('Leaf\App')) {
app()->config('db', $this->config);
app()->config('db.config', $this->config);
}

if ($host !== '') {
Expand Down Expand Up @@ -263,12 +263,13 @@ public function table(string $table): self
public function config($name, $value = null)
{
if (class_exists('Leaf\App') && function_exists('app')) {
if (is_array($name)) {
$this->config = array_merge($this->config, $name);
app()->config('db', array_merge(app()->config('db'), $this->config));
} else {
return app()->config("db.$name", $value);
$this->config = array_merge($this->config, $name);

if (!is_array($name)) {
$this->config[$name] = $value;
}

app()->config('db.config', array_merge(app()->config('db.config'), $this->config));
} else {
if (is_array($name)) {
$this->config = array_merge($this->config, $name);
Expand Down

0 comments on commit 068de19

Please sign in to comment.