mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
修正Loader类的table方法
This commit is contained in:
@@ -102,22 +102,21 @@ class Loader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实例化一个没有模型文件的Model
|
* 实例化一个没有模型文件的Model(对应数据表)
|
||||||
* @param string $name Model名称 支持指定基础模型 例如 MongoModel:User
|
* @param string $name Model名称 支持指定基础模型 例如 MongoModel:User
|
||||||
* @param string $tablePrefix 表前缀
|
* @param array $options 模型参数
|
||||||
* @param mixed $connection 数据库连接信息
|
|
||||||
* @return Model
|
* @return Model
|
||||||
*/
|
*/
|
||||||
static public function table($name = '', $tablePrefix = '',$connection = '') {
|
static public function table($name = '', $options=[]) {
|
||||||
static $_model = [];
|
static $_model = [];
|
||||||
if(strpos($name, ':')) {
|
if(strpos($name, ':')) {
|
||||||
list($class, $name) = explode(':', $name);
|
list($class, $name) = explode(':', $name);
|
||||||
}else{
|
}else{
|
||||||
$class = 'Think\Model';
|
$class = 'Think\Model';
|
||||||
}
|
}
|
||||||
$guid = $tablePrefix . $name . '_' . $class;
|
$guid = $name . '_' . $class;
|
||||||
if (!isset($_model[$guid]))
|
if (!isset($_model[$guid]))
|
||||||
$_model[$guid] = new $class($name, ['table_prefix' => $tablePrefix, 'connection' => $connection]);
|
$_model[$guid] = new $class($name, $options);
|
||||||
return $_model[$guid];
|
return $_model[$guid];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user