I have a CLI script that on first start:
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 work for several days. How can I open mysql connection? or before each mysql_query do I need to check if the whole connection is open?
This is a receiving error: MySQL Error: MySQL server has gone away
Thanks!
source share