经常遇到SQLSTATE[HY000] [1040] Too many connections,是有什么开发模式和传统的有区别吗

gddd
//请求token
    protected $token;

    //请求控制器模型
    protected $model;

    //当前请求对象
    protected $request;

    /**
     * 该方法会在请求前调用
     */
    public function beforeAction(Request $request)
    {
        $this->request = $request;
        $model = str_replace('controller', 'model', str_replace('Controller', '', $request->controller));
        if (class_exists($model)) {
            $this->model = new $model;
        }
        $this->token = $request->post('token');
    }

我在base控制器中这样写的

4292 1 0
1个回答

walkor

webman是数据库单例,一般是1个进程1个mysql连接。除非你开了很多进程超过mysql服务端最高连接数限制才会有Too many connections。也有可能你用了什么特殊的用法,绕过了数据库单例导致。

  • 暂无评论
年代过于久远,无法发表回答
🔝