zoukankan      html  css  js  c++  java
  • Laravel框架 redis hget() scontains()方法报错解决 阿星小栈

    问题代码:

    if(!Redis::scontains($redisKey, $path)){
                    return response()->json([
                        'code' => 99998,
                        'message' => '无操作权限'
                    ], 200);
    }
    
    if(!Redis::hget($redisKey, 'admin_id')){
                    return response()->json([
                         'code' => -1,
                         'message' => '未登录'
                     ], 200);
    }

    将获取结果放在条件里面做判断报错

    解决办法用   try{   }catch(){   }

    try{
                    $contain = Redis::scontains($redisKey,$path);
                }catch (Exception $exception){
                    $contain = false;
                }
                if(!$contain){
                    return response()->json([
                        'code' => 99999,
                        'message' => '无权限操作'
                    ],200);
    }
    
    try{
                $adminId = Redis::hget($redisKey, 'admin_id');
            }catch (Exception $e){
                $adminId = 0;
            }
    
             if(!$adminId){
                return response()->json([
                    'code' => -1,
                    'message' => '未登录'
                ], 200);
    }
  • 相关阅读:
    OpenFileMapping
    findwindow
    CopyMemory
    SetWindowsHookEx
    fillchar
    什么是ashx文件
    WPF中的控件
    WPF X名称空间里都有什么
    XAML语法学习之...
    Repeater控件使用总结
  • 原文地址:https://www.cnblogs.com/dereckbu/p/8204003.html
Copyright © 2011-2022 走看看