KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
This is kind of similar to this question: PHP MySQL INSERT fails due to unique constraint but I have a different twist. Let's say I have a table with only one column. The column's name is "title" and it has a unique constraint placed on it. First I insert a row where title = "something". The next time I try to insert "something" it will fail due to a unique key constraint (which is good). What I'd like to do is allow it to fail, and check the error code provided by mysql to ensure it failed due to a unique key constraint. (i.e. let the database handle the uniqueness, and I just handle the error code and tell the user that title already exists when the result comes back). Is there a way to do this?
Tags (comma-separated)
Save Edits
Cancel