|
@@ -434,32 +434,67 @@ function getIp(){
|
|
|
*/
|
|
|
function Model($model = null, $base_path = null)
|
|
|
{
|
|
|
- static $_cache = array();
|
|
|
- $cache_key = $model.'.'.$base_path;
|
|
|
- if (!is_null($model) && isset($_cache[$cache_key]))
|
|
|
- {
|
|
|
- $ret = $_cache[$cache_key];
|
|
|
- $ret->init($model);
|
|
|
- return $_cache[$cache_key];
|
|
|
- }
|
|
|
+ if(is_mobile())
|
|
|
+ {
|
|
|
+ static $name_cache = array();
|
|
|
|
|
|
- $base_path = $base_path == null ? BASE_DATA_PATH : $base_path;
|
|
|
- $file_name = $base_path.'/model/'.$model.'.model.php';
|
|
|
- $class_name = $model.'Model';
|
|
|
+ $base_path = $base_path == null ? BASE_DATA_PATH : $base_path;
|
|
|
+ $file_name = $base_path.'/model/'.$model.'.model.php';
|
|
|
+ $class_name = $model.'Model';
|
|
|
|
|
|
- if (!file_exists($file_name)){
|
|
|
- return $_cache[$cache_key] = new Model($model);
|
|
|
- }
|
|
|
+ if(array_key_exists($class_name,$name_cache)) {
|
|
|
+ return new $class_name();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (!file_exists($file_name)){
|
|
|
+ return new Model($model);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ require_once($file_name);
|
|
|
+
|
|
|
+ if (!class_exists($class_name)) {
|
|
|
+ $error = 'Model Error: Class '.$class_name.' is not exists!';
|
|
|
+ throw_exception($error);
|
|
|
+ } else {
|
|
|
+ $name_cache[$class_name] = $class_name;
|
|
|
+ return new $class_name();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
- require_once($file_name);
|
|
|
- if (!class_exists($class_name)) {
|
|
|
- $error = 'Model Error: Class '.$class_name.' is not exists!';
|
|
|
- throw_exception($error);
|
|
|
- }else{
|
|
|
- return $_cache[$cache_key] = new $class_name();
|
|
|
- }
|
|
|
- }
|
|
|
+ static $_cache = array();
|
|
|
+ $cache_key = $model.'.'.$base_path;
|
|
|
+ if (!is_null($model) && isset($_cache[$cache_key]))
|
|
|
+ {
|
|
|
+ $ret = $_cache[$cache_key];
|
|
|
+ $ret->init($model);
|
|
|
+ return $_cache[$cache_key];
|
|
|
+ }
|
|
|
+
|
|
|
+ $base_path = $base_path == null ? BASE_DATA_PATH : $base_path;
|
|
|
+ $file_name = $base_path.'/model/'.$model.'.model.php';
|
|
|
+ $class_name = $model.'Model';
|
|
|
+
|
|
|
+ if (!file_exists($file_name)){
|
|
|
+ return $_cache[$cache_key] = new Model($model);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ require_once($file_name);
|
|
|
+ if (!class_exists($class_name)) {
|
|
|
+ $error = 'Model Error: Class '.$class_name.' is not exists!';
|
|
|
+ throw_exception($error);
|
|
|
+ }else{
|
|
|
+ return $_cache[$cache_key] = new $class_name();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|