[求助]thinkPHP6.0使用Model层遇到的一个问题

浏览:781 发布日期:2020/07/03 分类:ThinkPHP6专区
大佬们新人求助!!!!!!

问题:model内部调用自身时抛出异常
异常:Call to a member function connect() on null
版本:thinkPHP v6.0.3(多应用)
代码如下: public static function cacheConfig($module='',$data=[]){
        if(empty($module)){
            throw new ConfigReadException('读取配置失败,本次异常已记录,请稍后访问');
        }

        if(!empty($data) && Cache::has($module)){
            if(array_key_exists(0,$data)){
                self::insertAll($data);
            }else{
                self::create($data);
            }
            Cache::clear($module);
        }

        if(!Cache::has($module)){
            try {
                $module_config = self::where('module', $module)->where('status', 1)->column('value', 'key');
            }catch (Exception $e){
                throw new ConfigReadException($e->getMessage());
            }
            if(empty($module_config)){
                throw new ConfigReadException('读取配置失败,本次异常已记录,请稍后访问');
            }
            Cache::set($module,$module_config);
        }

        return Cache::get($module);
    }
Emmm.... 图片不能上传所以也就没得异常页面的截图 凑活看!
最佳答案
评论( 相关
后面还有条评论,点击查看>>