title: How can I implement a database class for all other classes?
body: <p>I have a large amount of classes for: a main forums class, a forum boards class, and a threads class.  These can be thought of as models in the context of my website.  </p>
  
  <p>The setup the previous web developer was using creates a new mysqli connection in each one of these classes and connects on instantiation of the class.  This means that in the threads page there are 3 different connections for forums, threads, and users.  This is obviously not ideal and I think not even optimal.</p>
  
  <p>I worked on a previous project in which I could simply just pass a new instance of the database class to the class I was using, but this isn't ideal because I need to instantiate multiple classes and passing a database instance to each class would defeat the purpose.</p>
  
  <p>In each of these classes, database calls are made so the database object/instance is needed within each class, without having to instantiate it 3+ separate times.</p>
  
  <p>For example, in the threads class you could have:</p>
  
  <pre><code>function get_threads($board_id) {
      return $this-&gt;con-&gt;query("some query");
  }
  </code></pre>
  
  <p>Does anyone know how I can go about achieving this?</p>