mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
模型类的connection属性和数据库默认配置合并
This commit is contained in:
@@ -156,8 +156,14 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
{
|
{
|
||||||
$model = $this->class;
|
$model = $this->class;
|
||||||
if (!isset(self::$links[$model])) {
|
if (!isset(self::$links[$model])) {
|
||||||
|
// 合并数据库配置
|
||||||
|
if (is_array($this->connection)) {
|
||||||
|
$connection = array_merge(Config::get('database'), $this->connection);
|
||||||
|
} else {
|
||||||
|
$connection = $this->connection;
|
||||||
|
}
|
||||||
// 设置当前模型 确保查询返回模型对象
|
// 设置当前模型 确保查询返回模型对象
|
||||||
$query = Db::connect($this->connection)->model($model, $this->query);
|
$query = Db::connect($connection)->model($model, $this->query);
|
||||||
|
|
||||||
// 设置当前数据表和模型名
|
// 设置当前数据表和模型名
|
||||||
if (!empty($this->table)) {
|
if (!empty($this->table)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user