title: Call to a member function query() on a non-object
body: <p>I am running PHP Version 5.1.6 when I try and run the code below it gives a fatal error of an object that has not been instantiated. As soon as I un-comment this line of code everything works.</p>
  <pre><code>//$cb_db = new cb_db(USER, PASSWORD, NAME, HOST);
  </code></pre>
  <p>Even though I have declared the $cb_db object as global within the method.</p>
  <pre><code>require_once ( ROOT_CB_CLASSES . 'db.php');
  
  $cb_db = new cb_db(USER, PASSWORD, NAME, HOST);
  
  class cb_user {
      protected function find_by_sql( $sql ) {
          global $cb_db;
  
          //$cb_db = new cb_db(USER, PASSWORD, NAME, HOST);
          $result_set = $cb_db-&gt;query( $sql );
          
          $object_array = array();
          while( $row = $cb_db-&gt;fetch_array( $result_set ) ) {
              $object_array[] = self::instantiate( $row );
          }
          return $object_array;
      }
  }
  </code></pre>