改进Model类 支持动态查询调用

This commit is contained in:
thinkphp
2016-05-18 17:42:36 +08:00
parent 2af19639cb
commit 811b22fe74
2 changed files with 4 additions and 4 deletions

View File

@@ -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);
}
}