Here is what I ended up doing that seems to work for the limited testing I have given it.  Thanks to "lamby" for the lastError tip as well on IRC.

$this->Session->setFlash('Please correct errors below.', 'flash_error');

//check for mysql errors like unique failures
$connection =& ConnectionManager::getInstance();
$source     =& $connection->getDataSource($this->MyModel->useDbConfig);
$db_error   =  $source->lastError();

if ( strstr($db_error, 'Duplicate') ) {
    $this->MyModel->invalidate('myfieldname');
}

I am only enforcing unique on one field in my table.  This would break if possibly another database throws an error that does not contain 'Duplicate' in the error message for a unique failure.  It might also fail if more than one field in the table is has the unique attribute (if that is even reasonable to do).

Thanks


On 9/4/06, AD7six <[EMAIL PROTECTED]> wrote:

Try this:

http://groups.google.com/group/cake-php/search?group=cake-php&q=nate+db+error

I often find that sticking "nate" on the end of searches narrows down
results to a manageable number (with relavent results) ;)

Cheers,

AD7six




--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to