title: using mysqli::prepare within an already established connection using prepare?
body: <p>Quick question. Whilst using the <code>prepare</code> method in mysqli. It is possible/a good idea; to use it twice within the same mysqli connection? Example:</p>
  
  <p>OOP layered</p>
  
  <pre><code>public function getStuff(){
      $posts=array();
      $query = $this-&gt;DBH-&gt;prepare('SELECT * FROM table WHERE stuff =?');
      $query-&gt;bind_param('s','param');
      $query-&gt;execute();
      $query-&gt;bind_result($ID,$col1,$col2,$etc);
      while($query-&gt;fetch()){
          $posts[]=array('ID'=&gt;$ID,'col1'=&gt;$col1,'extras'=&gt;$this-&gt;getExtras($ID));
      }
      $query-&gt;close();
      return $posts;
  }
  private function getExtra($postID){
      $extras=array();
      $query = $this-&gt;DBH-&gt;prepare('SELECT * FROM anotherTable WHERE moreStuff =?');
      $query-&gt;bind_param('s',$postID);
      $query-&gt;execute();
      $query-&gt;bind_result($ID,$col1,$col2,$etc);
      while($query-&gt;fetch()){
          $extras[]=array('ID'=&gt;$ID,'col1'=&gt;$col1,'etc'=&gt;$etc);
      }
      $query-&gt;close();
      return $extras;
  }
  </code></pre>
  
  <p>Right my possible error is that I've used the same variable and the same database connection. I'm not 100% sure this will work as I've called $this->DBH whilst it is already being used in the parent function. Is there a better method to what I'm trying to achieve or is there a better structure I can use. Or should I just give up and use a separate variable? lol</p>
  
  <p>Hopeful outcome:</p>
  
  <pre><code>$posts=array('ID'=&gt;'column ID number','col1'=&gt;'column1 data', 'extras'=&gt;array('ID'=&gt;'second table\'s ID number','col1'=&gt;'second tables data','etc'=&gt;'etc etc etc'));
  </code></pre>