Is it possible to create a trigger that, upon inserting or updating a row, can use the REPLACE function to replace characters with their escaped equivalents (specifically, making input html safe) for all the columns in the table without having to know all the field names (so that this function can be applied to multiple tables). I agree 115% that this sort of thing should always be done at the application level, but due to unique circumstances I'd like to add this as a failsafe at the database level.
I'm very new to triggers, so take it easy on me, but I want to do something to the effect of:
create trigger if not exists makeHTMLsafe after insert on tablename
begin
loop over all columns in tablename
new.value = REPLACE(old.value,"<","<")
end