title: Recommended way for passing data connection to a PHP class / method?
body: <p>As of right now I have a database connection string included at the top of each of my pages. I'm then passing my database connection to the methods in my class like this:</p>
  
  <pre><code>public function select($db) {
    //Code here
  }
  </code></pre>
  
  <p>Code on page:</p>
  
  <pre><code>$login_user-&gt;select($db);
  </code></pre>
  
  <p>My thought is that if I ever want to query a different database I can just create a new connection string in my include file called $db2 and then I just pass that value instead of $db.</p>
  
  <p>Is this a standard way of doing this or do you have a different recommendation?</p>