I have a CLI script which when you first start it:
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);
}
}
This CLI script can stay running for days. How do i keep the mysql connection open? or before each mysql_query do i have to check if the connection is still open?
This is the error im getting:
MySQL Error: MySQL server has gone away
Check this : https://www.digitalocean.com/community/questions/how-to-set-no-timeout-to-mysql
In particular, it is stated:
The server timed out and closed the connection. By default, the server closes the connection after 8 hours or 28800 seconds if nothing has happened. You can change the time limit by setting the wait_timeout variable when you start mysqld via your server’s /etc/my.cnf [...]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With