I have a MySQL Insert query, which is likely to produce a duplicate, which results in an error message (with mysql_error()
) like this
Duplicate entry '1-79' for key 'PRIMARY'
Is there a way to get this with a little more structure, so I know which key produced the duplicate. Maybe something like an array that looks a little like this
["Error" => "1062", "entry" => "1-79", "key" => "PRIMARY"]
so that i know immediately which column to change.
I do not want an INSERT IGNORE
or ON DUPLICATE UPDATE
, i just want an easy way to process the error.
Does that exist, or do i have to somehow process the mysql_error()
string?