mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
修正M函数和Model类 支持传入空白的表前缀
例如 M('User','') 或者 Loader::table('User',['prefix'=>'']);
This commit is contained in:
@@ -72,11 +72,11 @@ function G($start, $end = '', $dec = 6)
|
||||
/**
|
||||
* 实例化一个没有模型文件的Model
|
||||
* @param string $name Model名称 支持指定基础模型 例如 MongoModel:User
|
||||
* @param string $tablePrefix 表前缀
|
||||
* @param string|null $tablePrefix 表前缀 null表示自动获取配置
|
||||
* @param mixed $connection 数据库连接信息
|
||||
* @return \Think\Model
|
||||
*/
|
||||
function M($name = '', $tablePrefix = '', $connection = '')
|
||||
function M($name = '', $tablePrefix = null, $connection = '')
|
||||
{
|
||||
return \think\Loader::table($name, ['prefix' => $tablePrefix, 'connection' => $connection]);
|
||||
}
|
||||
|
||||
@@ -76,6 +76,8 @@ class Model
|
||||
|
||||
if (!empty($config['prefix'])) {
|
||||
$this->tablePrefix = $config['prefix'];
|
||||
} elseif ('' === $config['prefix']) {
|
||||
$this->tablePrefix = '';
|
||||
} elseif (is_null($this->tablePrefix)) {
|
||||
$this->tablePrefix = Config::get('database.prefix');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user