diff --git a/base.php b/base.php index c72365eb..e7580972 100644 --- a/base.php +++ b/base.php @@ -90,7 +90,7 @@ function G($start,$end='',$dec=6) { * @return Model */ function M($name='', $tablePrefix='',$connection='') { - return think\Loader::table($name,['table_prefix'=>$tablePrefix,'connection'=>$connection]); + return think\Loader::table($name,['prefix'=>$tablePrefix,'connection'=>$connection]); } /** diff --git a/library/think/model.php b/library/think/model.php index 833b937c..f55a0ff5 100644 --- a/library/think/model.php +++ b/library/think/model.php @@ -69,6 +69,8 @@ class Model { if(isset($config['prefix'])) { $this->tablePrefix = $config['prefix']; + }else{ + $this->tablePrefix = Config::get('database.prefix'); } if(isset($config['connection'])) { $this->connection = $config['connection'];