[eluser]BrianDHall[/eluser]
Handy little piece of code that I was afraid might not work, but it did anyway!
I had a form voting system that keeps track of votes using a voters email address. In my Voters table I only wanted one entry for each unique email.
When submitting a vote (there is no login system) I wanted to either use an existing Voter, or if one didn't exist with that email address then I wanted to go ahead and create one and continue. It turns out this worked exactly like I hoped it might:
Code:
$voter->email = $email;
if ($voter->save() || $voter->get()->exists())...
Just that easy, if it fails validation and can't be saved because email is already taken then it just grabs out that existing record and allows you to continue on with your function.