Mysql has gone away

浏览:1097 发布日期:2015/06/16 分类:求助交流
最近用TP写脚本跑数据同步,经常出现Mysql has gone away错误,
我是这么解决的:
在php.ini中设置mysqli.reconnect = On (本人用的mysqli)
然后在TP Think\Db\Driver\Mysqli.php中
加入方法private function ping($flag) {
        if($this->_linkID){
            $pflag = $this->_linkID->ping();
            if(!$pflag) {
                $this->close();
            }
            $this->initConnect($flag);
        }
    }
然后,次文件中的$this->initConnect(true); // 换成 $this->ping(true);有大神看看这么做行不行,SOS
最佳答案
评论( 相关
后面还有条评论,点击查看>>