title: Get last inserted ID from doctrine and native mysql query
body: <p>I'm using doctrine in symfony2. But I used native mysql query to insert some data. Now I want the last inserted id from the database. My code looks like:</p>
  
  <pre><code>$stmt = $this-&gt;getDoctrine()-&gt;getManager()
               -&gt;getConnection()
               -&gt;prepare("INSERT INTO tb_company (v1,v2,v3) values('$v1','$v2','$v3')");
  $stmt-&gt;execute();
  </code></pre>
  
  <p>So to recover the last inserted id I tried</p>
  
  <pre><code>$stmt-&gt;insert_id; 
  
  $id=LAST_INSERT_ID(id)
  
  $id=$stmt-&gt;getId();
  </code></pre>
  
  <p>and many other. None of them worked for me. I'm new to doctrine. <strong>How to get the last inserted ID from here?</strong> What I'm missing?</p>