How add trigger to mysql Through Schema API

2019-06-09 10:24发布

问题:

Through Schema API (file mymodule.install in Folder sites\all\modules\mymodule). trigger in mysql:

delimiter |

    CREATE TRIGGER testref AFTER INSERT ON users
      FOR EACH ROW BEGIN
        INSERT INTO beep  SET uid = NEW.uid;
      END;
    |

    delimiter ;

回答1:

There is no specific API for that.

Try http://api.drupal.org/api/drupal/includes--database.pgsql.inc/function/db_query/6

Also remember that triggers are not standardised across different databases. It would be a better idea (or maybe as a fallback) to do that with hook_user().