i have a t_provider table which is used as lookup by t_shortcode (where t_provider.f_provideruid = t_shortcode.f_provideruid).
when user wants to delete a record in the t_provider, i check if the f_provideruid is already used in the t_shortcode and if so, do not allow deletion and inform the user why.
I used two events, the BeforeDelete and ListOnLoad for t_provider:
BeforeDelete:
$strSQLCheck = "select f_provideruid from t_shortcode where f_provideruid=$deleted_values[f_provideruid]";
global $message;
global $conn;
$cid=db_exec($strSQLCheck,$conn);
if (db_numrows($cid)+0 != 0){
$message="Provider already has Short Code entries. Cannot be deleted.";
return false;
}else{
$message="";
return true;
}
ListOnLoad:
global $message;
if (!empty($message)){
echo "<script language=javascript>alert('$message');</script>";
}
$message="";
Is there a better way of doing this?