title: Check if entity already exists in database before inserting with Doctrine
body: <p>Whenever I insert an entity that already exists in the database, I get an error because there is a unique constraint on one of the fields (<code>email</code>).</p>
  
  <p>So I want to check if it already exists; if not, I insert it.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>$q = Doctrine_Query::create()
      -&gt;from('User u')
      -&gt;where('u.email = ?', $email);
  
  $object = $q-&gt;fetchOne();
  
  if( ! is_object($object)) {
            $user = new User();
            $user-email = $email;
            $user-&gt;save();
      }
  </code></pre>
  
  <p>Is there an easier way to do this?</p>