title: How to make instance of one class to be instance of another class
body: <p>I have custom db class which extends MySQLi class
  MySQLi->query() method returns obejct with MySQLi_Result class, but I want to extend funcionality of this class and somehow make result object to be MyResult class. Something like this:</p>
  
  <pre><code>class MyResult extends MySQLi_Result{
    function abc(){
      //...
    }
  }
  
  class MyDB extends MySQLi{
    function q($query){
      return /*Here some magic*/ $this-&gt;query();
    }
  }
  
  $db=new MyDB();
  $res=$db-&gt;q('SEL...');
  $res-&gt;abc();
  </code></pre>
  
  <p>How to do this?</p>
  
  <p>EDIT:
  Some say that this is duplicate, but problem here is deeper!
  I need that $result object would act like Mysqli_result class obect, so the old code would work.
  So I need that, I can call original Mysqli_result methods like:</p>
  
  <pre><code>$res-&gt;fetch_assoc();
  
  //but not
  $res-&gt;result-&gt;fetch_assoc();
  </code></pre>