2580 Posts in 695 Topics by 540 members
Data Model Questions
SilverStripe Forums » Data Model Questions » Unique key and exception hanhling
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 263 Views |
-
Unique key and exception hanhling

23 August 2011 at 1:22am
I have unique index on two fields (COL1,CoL2)
I wanna write it to DB, but on failure I don't want to throw any user error. Just that one that I want to show. I made
try {
$branch->write();
}
catch(ValidationException $e) {
$bad++
show_error_with_bad_results($bad);
}but It doesn't seem to catch it. I t throws user error instead. How could I make it work.
-
Re: Unique key and exception hanhling

23 August 2011 at 8:08pm
SS doesn't use exceptions very much, I think in this case you'll need to manually do your insert or detect the conflict. There is a plan to get us away from the user_error() world but that's a big task!
-
Re: Unique key and exception hanhling

23 August 2011 at 8:35pm
I thought I can make it by DO, if now well... Thank You anyway.
M.
| 263 Views | ||
|
Page:
1
|
Go to Top |


