title: Pass mysqli object to class
body: <p>I want to pass a mysqli object to a class. I create the object in one file:</p>
  
  <pre><code>$host = 'host';
  $user = 'username';
  $pw = 'pw';
  $db = 'db';
  
  $link = new mysqli($host,$user,$pw,$db);
  </code></pre>
  
  <p>which is included in one page:</p>
  
  <pre><code>include 'php/mysql.php';
  include 'php/classes/Class.Dataconnector.php';
  $dc = new Dataconnector($link);
  </code></pre>
  
  <p>and the class looks like this:</p>
  
  <pre><code>class Dataconnector {
      protected $_link;
      protected $_stub;
  
      function __construct(mysqli $link) {
          $_link = $link;
      }
  
      public function getPageContent($stub) {
          $query = "select * from contents where pageId = (select id from pages where stub = '$stub')";
          $result = mysqli_query($_link,$query);
          return $result;
      }
  }
  </code></pre>
  
  <p>But I get this error:</p>
  
  <pre><code>Warning: mysqli_query() expects parameter 1 to be mysqli, null given in \php\classes\Class.Dataconnector.php on line 18
  </code></pre>
  
  <p>What is wrong ?</p>