title: OOP PHP Can't get new mysqli from other class
body: <p>I have class, where i make connection to database and do some queries.</p>
  
  <p>But i can't make query to this database from other class. Problem is that class <code>Cd</code> can't see db connection command -> can't make a query. Here is the code:</p>
  
  <pre><code>require_once('config.php');
  class myClass
  {
      public $mysqli;
      public $res;
      function connect()
      {
          $database = new Database();
  
          $this-&gt;mysqli = new mysqli($database-&gt;db_host, $database-&gt;db_user, $database-&gt;db_pass, $database-&gt;db_table);
      }
      function cd($id)
      {
         ......
          }
      }        
  }
  
  class Cd extends myClass
  {
      function cdname($id)
      {
          $get= new Scandiweb();
          $get-&gt;mysqli;
  
          $this-&gt;res = $get-&gt;mysqli-&gt;query("SELECT * FROM disk WHERE id=" . $id . "");
          if ($this-&gt;res-&gt;num_rows &gt; 0) {
              .........
          }
      }
  }
  </code></pre>