Problem #102 solved.
I won't specify a constraint name and will let MySQL handle it, as it automatically generates a name for it. This auto-generated name typically follows a pattern like tablename_ibfk_n, where n is a number that increments for each new unnamed foreign key constraint added to the table.
Which is exactly what the original code was trying to do, minus the increment.
Bonus: I also add a feature to retrieve the correct key name in the confirmation message, because if you add multiple constraints on the same column, you have to query the last one that was added.
The confirmation error is still displayed at the top of the page without the Boostrap .alert style, but we'll deal with that later.
Problem #102 solved. I won't specify a constraint name and will let MySQL handle it, as it automatically generates a name for it. This auto-generated name typically follows a pattern like
tablename_ibfk_n
, wheren
is a number that increments for each new unnamed foreign key constraint added to the table.Which is exactly what the original code was trying to do, minus the increment.
Bonus: I also add a feature to retrieve the correct key name in the confirmation message, because if you add multiple constraints on the same column, you have to query the last one that was added.
The confirmation error is still displayed at the top of the page without the Boostrap .alert style, but we'll deal with that later.