title: Check that record is successfully inserted in Symfony2
body: <p>How can I check if a record is successfully inserted in database using Doctrine in symfony2?</p>
  
  <p>My action in controller is</p>
  
  <pre><code>public function createAction(){
      $portfolio = new PmPortfolios();
      $portfolio-&gt;setPortfolioName('Umair Portfolio');
      $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
      $em-&gt;persist($portfolio);
      $em-&gt;flush();
      if(){
           $this-&gt;get('session')-&gt;setFlash('my_flash_key',"Record Inserted!");
      }else{
           $this-&gt;get('session')-&gt;setFlash('my_flash_key',"Record notInserted!");
      }
  }
  </code></pre>
  
  <p>What should I write in the <code>if</code> statement?</p>