title: PHP: How to determine if a database connection is open
body: <p>I have the following class method - </p>
  
  <pre><code>class Someclass
  {
      /* Other properties and methods */
  
      public function close_connection($connection=NULL)
      {
          return mysql_close($connection)
      }
  }
  </code></pre>
  
  <p>Now, before calling the <code>mysql_close</code> function in the above code, I want to check if the <code>$connection</code> points to a open database connection. That is, I want to be sure that the connection I am closing is open and has not already been closed.</p>
  
  <p>How can I do that?</p>