title: Symfony - I need to insert or update a record in database
body: <p>The primary key is Id, but i want to check if already exists a record in db with same acronym, and if not, insert a new one, if exists, I need to do an update. I wrote this code, but it doesn't work. I receive this message from symfony "Integrity violation: 1062 Duplicate entry '180' for key 'PRIMARY'"</p>
  
  <pre><code>$id = Doctrine_Core::getTable('college')-&gt;findBy('acronym', 'PMM')-&gt;getFirst()-&gt;getId();
  $college = new college();
  $college-&gt;setId($id);
  $college-&gt;setAcronym('PMM');
  $college-&gt;setName('Paulo Miguel Mar');
  $college-&gt;setUrl('www.pmm.com');
  $college-&gt;save();
  </code></pre>
  
  <p>Anyone can help me?
  Thanks.
  Alexandre Sousa</p>
  
  <hr>
  
  <p>I've tried the replace() solution, but I have some problems because I want to keep my id field. So I wanna do an update and not a replace. </p>
  
  <p>I think save() should works, cause I read somewhere that this function is smart enough to do an update or insert. I still get this message: "Integrity violation: 1062 Duplicate entry '180' for key 'PRIMARY"</p>
  
  <p>Anyone can help me?</p>
  
  <p>Thanks.</p>