问题: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.... 图片不能上传所以也就没得异常页面的截图 凑活看! 最佳答案