title: How long does a mysql_connect stay open?
body: <p>I have a CLI script which when you first start it:</p>
  
  <pre><code>function __construct(){$this-&gt;connectToDatabase();}
  protected function connectToDatabase(){
      try{
          $this-&gt;databaseName = $this-&gt;dbname;
          $this-&gt;posName = $this-&gt;posName;
          $this-&gt;vlog = $this-&gt;vlogName;
          $this-&gt;database = mysql_connect($this-&gt;dbhost, $this-&gt;dbuser, $this-&gt;dbpass);
          mysql_select_db($this-&gt;databaseName, $this-&gt;database);
      }
      catch(Exception $e){
          $this-&gt;console($e);
      }
  }
  </code></pre>
  
  <p>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?</p>
  
  <p>This is the error im getting: </p>
  
  <blockquote>
    <p>MySQL Error: MySQL server has gone away</p>
  </blockquote>