我有一个命令行脚本,当你第一次启动它:mysql_connect保持打开状态多久?
function __construct(){$this->connectToDatabase();}
protected function connectToDatabase(){
try{
$this->databaseName = $this->dbname;
$this->posName = $this->posName;
$this->vlog = $this->vlogName;
$this->database = mysql_connect($this->dbhost, $this->dbuser, $this->dbpass);
mysql_select_db($this->databaseName, $this->database);
}
catch(Exception $e){
$this->console($e);
}
}
此CLI脚本可以保持运行几天。我如何保持MySQL连接打开?或者在每个mysql_query之前,我必须检查连接是否仍然打开?
这是错误即时得到:MySQL Error: MySQL server has gone away
谢谢!
你有任何与此问题?连接应该保持打开状态(除非有一些设置限制了服务器上可以打开连接的时间)。 – 2011-03-22 21:03:58
是的,我有问题。基本上这是一个接受websocket连接的'服务器'cli。由于某种原因,当我尝试连接一天latr我得到了'MySQL错误:MySQL服务器已经消失'错误 – Neal 2011-03-22 21:05:26