Unique key constraint mysql/maria internal error message

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
swiftinitpvtltd
Posts: 370
Joined: Sat Apr 28, 2018 3:33 am
Location: India
Contact:

Unique key constraint mysql/maria internal error message

Post by swiftinitpvtltd »

WE have a unique key constraint on database table(safest approach to avoid duplicates) but when aware tries to add a record with duplicate directly shows database unique constraint error message. How do we modify this database message to make it user friendly? (shows Internal error- "error adding reference duplicate entry"

Constraint on a table-
ALTER TABLE table_name
ADD CONSTRAINT constraint_name UNIQUE KEY(column_1,column_2,...);
swiftinitpvtltd
Posts: 370
Joined: Sat Apr 28, 2018 3:33 am
Location: India
Contact:

Re: Unique key constraint mysql/maria internal error message

Post by swiftinitpvtltd »

How do we do below in aware?
https://stackoverflow.com/questions/102 ... or-message

$result = mysql_query('... query that produces duplicate key error ...');
if ($result === FALSE) {
if (mysql_errno() == 1022) {
die("Username already exists");
} else {
die(mysql_error());
}
}
Post Reply