Programmer Question
In my php/MySQL code I insert new record into a table (InnoDB) which has many UNIQUE column keys. If insertion fails (with ER_DUP_ENTRY) I need to know which column's value wasn't unique.
I was told that to achieve this, you must extract value of %d from error message you get:
"Duplicate entry '%s' for key %d".
This should work but I don't like the solution. Parsing/regex matching some string gives unnecessary complexity to simple task I always try to avoid. Now the question: is this the right way to go? Isn't there any better solution?
Find the answer here
No comments:
Post a Comment