My model has 2 unique indexes. The primary key, and an alphanumeric id.
I only have the alphanumeric id when updating said record, so I need to add an “on duplicate key update” statement to the save function, but how do I do that?
And I do not want to query for the primary key first, as that would make the import process incredibly long and slow.
There is no supported ‘on duplicate key update’ options in cakephp.
If you really do not want to do the lookup, I would suggest changing the alphanumeric id to the primary key (as long as it is something like a UUID and not a varchar). If that is not an option, my best advice is to add a beforeSave method that does the integrity check.
Here is a link that can help Cakephp check if record exists