Convert DB triggers to PHP function

Convert triggers due to limitation in Godaddy