From 811b22fe74a206853370fe8e93be01117ee2174f Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 18 May 2016 17:42:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BModel=E7=B1=BB=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=8A=A8=E6=80=81=E6=9F=A5=E8=AF=A2=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 6 +++--- library/think/model/Merge.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 9903370b..2179920d 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -859,10 +859,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess /** * 初始化数据库对象 - * @access public + * @access protected * @return \think\db\Query */ - public static function db() + protected static function db() { $model = get_called_class(); if (!isset(self::$links[$model])) { @@ -894,7 +894,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess call_user_func_array([$this, $method], $args); return $this; } else { - throw new Exception(__CLASS__ . ':' . $method . ' method not exist'); + return call_user_func_array([self::db(), $method], $args); } } diff --git a/library/think/model/Merge.php b/library/think/model/Merge.php index 6f35b297..05918fac 100644 --- a/library/think/model/Merge.php +++ b/library/think/model/Merge.php @@ -66,7 +66,7 @@ class Merge extends Model foreach (static::$relationModel as $key => $model) { $name = is_int($key) ? $model : $key; - $table = is_int($key) ? self::db()->getTable($name) : $model; + $table = is_int($key) ? $query->getTable($name) : $model; $query->join($table . ' ' . $name, $name . '.' . $class->fk . '=' . $master . '.' . $class->getPk()); $fields = self::getModelField($name, $table, $class->mapFields); $query->field($fields);