mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 23:52:49 +08:00
改进Model类db方法
This commit is contained in:
@@ -169,11 +169,15 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
$model = $this->class;
|
$model = $this->class;
|
||||||
if (!isset(self::$links[$model])) {
|
if (!isset(self::$links[$model])) {
|
||||||
// 合并数据库配置
|
// 合并数据库配置
|
||||||
|
if (!empty($this->connection)) {
|
||||||
if (is_array($this->connection)) {
|
if (is_array($this->connection)) {
|
||||||
$connection = array_merge(Config::get('database'), $this->connection);
|
$connection = array_merge(Config::get('database'), $this->connection);
|
||||||
} else {
|
} else {
|
||||||
$connection = $this->connection;
|
$connection = $this->connection;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$connection = [];
|
||||||
|
}
|
||||||
// 设置当前模型 确保查询返回模型对象
|
// 设置当前模型 确保查询返回模型对象
|
||||||
$query = Db::connect($connection)->model($model, $this->query);
|
$query = Db::connect($connection)->model($model, $this->query);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user