title: Doctrine - best way to check for a record, then either update or add
body: <p>I've come across this scenario a few times in working on a current project. I have to see if a record exists then if it doesn't I need to add it, if it does then I need to update. What is the standard way of doing this with Doctrine?</p>
  
  <p>I seem to be querying to see if the record exists using a find* method. Then if that returns a positive result (object), I use that object to update. Otherwise, (no record found) I have to create another object and save().</p>
  
  <p>For some reason this just seems inefficient. Is there a better way or am I just being weird? :)</p>
  
  <pre><code>$user = Doctrine_Core::getTable('Model_User')-&gt;findOneByEmail('myemail@email.com');
  if (!$user) {
      $user = new Model_User();
      $user-&gt;fromArray($values); // $values comes from form or wherever
      $user-&gt;save();
  } else {
      $user-&gt;fromArray($values);
      $user-&gt;save();
  }
  </code></pre>