diff --git a/library/think/ORM.php b/library/think/ORM.php new file mode 100644 index 00000000..eb104905 --- /dev/null +++ b/library/think/ORM.php @@ -0,0 +1,28 @@ + +// +---------------------------------------------------------------------- + +namespace think; + +class ORM +{ + protected static $instance = []; + protected static $config = []; + + public static function __callStatic($method, $params) + { + $name = basename(get_called_class()); + if (!isset(self::$instance[$name])) { + // 自动实例化模型类 + self::$instance[$name] = new \think\Model($name, static::$config); + } + return call_user_func_array([self::$instance[$name], $method], $params); + } +}