drupaldrupal-6drupal-modules

How add trigger to mysql Through Schema API


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 ;

Solution

  • 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().