改名
This commit is contained in:
+25
-1
@@ -14,6 +14,7 @@ use Database\Db;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use JetBrains\PhpStorm\ArrayShape;
|
use JetBrains\PhpStorm\ArrayShape;
|
||||||
|
|
||||||
|
use Snowflake\Abstracts\Config;
|
||||||
use Snowflake\Abstracts\Input;
|
use Snowflake\Abstracts\Input;
|
||||||
use Snowflake\Exception\ComponentException;
|
use Snowflake\Exception\ComponentException;
|
||||||
use Snowflake\Exception\ConfigException;
|
use Snowflake\Exception\ConfigException;
|
||||||
@@ -110,10 +111,33 @@ class Gii
|
|||||||
*/
|
*/
|
||||||
private function getModel($make, $input): array
|
private function getModel($make, $input): array
|
||||||
{
|
{
|
||||||
if (!$this->db) {
|
if ($this->db) {
|
||||||
|
return $this->makeByDatabases($make, $input);
|
||||||
|
}
|
||||||
|
if ($this->input->exists('databases')) {
|
||||||
$db = $this->input->get('databases', 'db');
|
$db = $this->input->get('databases', 'db');
|
||||||
$this->db = Snowflake::app()->db->get($db);
|
$this->db = Snowflake::app()->db->get($db);
|
||||||
|
|
||||||
|
return $this->makeByDatabases($make, $input);
|
||||||
}
|
}
|
||||||
|
$array = [];
|
||||||
|
foreach (Config::get('databases') as $key => $connection) {
|
||||||
|
$this->db = Snowflake::app()->db->get($key);
|
||||||
|
|
||||||
|
$array[$key] = $this->makeByDatabases($make, $input);
|
||||||
|
}
|
||||||
|
return $array;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $make
|
||||||
|
* @param $input
|
||||||
|
* @return array
|
||||||
|
* @throws ComponentException
|
||||||
|
*/
|
||||||
|
private function makeByDatabases($make, $input): array
|
||||||
|
{
|
||||||
$redis = Snowflake::app()->getRedis();
|
$redis = Snowflake::app()->getRedis();
|
||||||
if (!empty($input->get('table'))) {
|
if (!empty($input->get('table'))) {
|
||||||
$this->tableName = $input->get('table');
|
$this->tableName = $input->get('table');
|
||||||
|
|||||||
@@ -45,6 +45,16 @@ class Input
|
|||||||
return $this->_argv[$key] ?? $default;
|
return $this->_argv[$key] ?? $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $key
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function exists($key): bool
|
||||||
|
{
|
||||||
|
return isset($this->_argv[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $key
|
* @param $key
|
||||||
* @param $value
|
* @param $value
|
||||||
|
|||||||
Reference in New Issue
Block a user