title: Use last inserted id to insert query
body: <p>I have a query like this:</p>
  
  <pre><code>&lt;?php   
  $this-&gt;db-&gt;query("INSERT INTO customer SET email = '" . $this-&gt;db-&gt;escape($data['email']) . "'");
  ?&gt;
  </code></pre>
  
  <p>And after this i need to make an INSERT to another table like this:</p>
  
  <pre><code>$this-&gt;db-&gt;query("INSERT INTO order SET customer_id = '" . //here goes the id i need from previous query ."'";
  </code></pre>
  
  <p>In my customer table i have only one auto-increment column called customer_id and after first insertion to this table i need to get this customer_id value and use it to the next insertion (to order table).</p>
  
  <p>How can i do this? I read about </p>
  
  <pre><code>$mysqli-&gt;insert_id
  </code></pre>
  
  <p>but all the examples connect to a database whereas i am already connected to database and run queries with this->db. Any help about syntax or other solution is really appreciated!</p>