I've tried to catch the duplicate entry error a bunch of times, but
have never had any luck.  I would love to see a solution for this.  I
realize I can check before trying the save, but if I'm importing some
large amount of data it would cause an extra query for every record.

As for using IsUnique I don't think it works real well just sticking
it in as a rule in validation.  Otherwise won't it fail on updates?
And if you set "on" => "create" won't that allow for duplicate names
on update?  I always end up using a custom rule to make sure that 1)
the username doesn't exist and 2) if it does it has the same id as the
data being saved.  Maybe I'm missing some Cake magic on this one.


-Matt
www.pseudocoder.com


On Mar 28, 11:58 am, Greg Baker <[EMAIL PROTECTED]> wrote:
> How can I capture a MySQL error like the following:
>
> Warning (512): SQL Error: 1062: Duplicate entry
> 'TestSlot-47e9547d-6570-4e3e-9834-16b88699522c' for key 2 [CORE/cake/
> libs/model/datasources/dbo_source.php, line 459]
>
> Basically I have a unique key set across two fields in a table so that
> if I add a 'Slot' which belongsTo a 'Conference' the slot name must be
> unique within that conference.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to