微擎开发使用workerman时,使用微擎pdo_xxx提示MySQL server has gone away解决办法

发布时间 2023-07-14 13:59:56作者: 阿怪11

微擎开发使用workerman时,使用微擎pdo_xxx提示MySQL server has gone away解决办法

# 找到微擎的DB类ramework\class\db.class.php

public function reConnect($errorInfo,$params) {
		if (in_array($errorInfo[1], array(1317, 2013))) {
			$this->pdo = null;
			$this->connect($this->name);
			$method = $params['method'];
			unset($params['method']);
			return call_user_func_array(array($this, $method), $params);
		}
		return false;
}
  • 代码中只有 1317 2013 才会重连
  • 直接在错误代码后增加2006即可。故批量替换下db.class.php【1317,2013】为【1317,2013, 2006】,一共6次。重启workerman,测试完美解决。