This commit is contained in:
2021-11-09 10:58:57 +08:00
parent 2ea8e8276b
commit 4d7c9fdd17
3 changed files with 20 additions and 13 deletions
+12 -1
View File
@@ -108,6 +108,17 @@ class Connection extends Component
}
/**
* @param $config
* @return $this
*/
public function configure($config): static
{
Kiri::configure($this, $config);
return $this;
}
/**
* @throws Exception
*/
@@ -141,7 +152,7 @@ class Connection extends Component
* @return mixed
* @throws ReflectionException
* @throws NotFindClassException
* @throws \Exception
* @throws Exception
*/
public function getSchema(): Schema
{
+7 -11
View File
@@ -6,13 +6,13 @@ namespace Database;
use Annotation\Inject;
use Exception;
use Server\Events\OnWorkerStart;
use Kiri\Abstracts\Config;
use Kiri\Abstracts\Providers;
use Kiri\Application;
use Kiri\Events\EventProvider;
use Kiri\Exception\ConfigException;
use Kiri\Kiri;
use Server\Events\OnWorkerStart;
/**
* Class DatabasesProviders
@@ -53,11 +53,9 @@ class DatabasesProviders extends Providers
*/
public function get($name): Connection
{
$application = Kiri::app();
if (!$application->has('databases.' . $name)) {
$application->set('databases.' . $name, $this->_settings($this->getConfig($name)));
}
return $application->get('databases.' . $name);
$config = $this->_settings($this->getConfig($name));
return Kiri::getDi()->get(Connection::class)->configure($config);
}
@@ -71,12 +69,10 @@ class DatabasesProviders extends Providers
if (empty($databases)) {
return;
}
$application = Kiri::app();
foreach ($databases as $name => $database) {
$connection = Kiri::getDi()->get(Connection::class);
foreach ($databases as $database) {
/** @var Connection $connection */
$application->set('databases.' . $name, $this->_settings($database));
$database = $application->get('databases.' . $name);
$database->fill();
$connection->configure($database)->fill();
}
}
+1 -1
View File
@@ -317,7 +317,7 @@ class Columns extends Component
/**
* @param $column
* @param array $column
* @param $table
* @return array
*/