I would suggest this comes down to application design and logic.

Your business logic should not be creating duplicates of SomeClass if
the instance already exists.

You can do one of two things:

1) Do a lookup to see if the key already exists
2) Add a try catch block around the statement and recover

Also consider using autonumber fields for your Id's, so you don't need
to calculate them.

Steve

On Mar 25, 5:20 pm, Joshua <[email protected]> wrote:
> $SomeClass= new SomeClass();
> $SomeClass->setId($number);
> $SomeClass->save();
>
> In this example if column ID is unique and there is already a row with
> ID $number then trying to save this object will get an SQL Insert
> rejection and crap the page.
>
> Following this futher...
>
> foreach($numbers as $number)
> {
> $SomeClass= new SomeClass();
> $SomeClass->setId($number);
> $SomeClass->save();
>
> }
>
> In that example if one of the objects fails it will do a full stop and
> you get an Oops page.
>
> Is there any way to get symfony to just skip over these failed cases
> and continue loading?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to