0
I am developing an application where the user type some information, two of them are Code Driver and Code.
This is an excerpt from my code:
try {
$database->query($sql);
$_SESSION['message'] = 'Registro cadastrado com sucesso.';
$_SESSION['type'] = 'success';
} catch (Exception $e) {
$_SESSION['message'] = 'Não foi possivel realizar a operação.';
$_SESSION['type'] = 'danger';
}
I am managing to do the normal registrations, the problem is that when the user informs a Code driver or Code that there is no system does not give a Exception (Should give a Exception because these data are Foreign Keys) the system does not even insert, what I need is to adapt this code to give an exception with the error or change the parameter of the condition, to inform the user that the registration gave error.
I used your 2 example, thank you very much for the past knowledge for me.
– user31040