Jump to content

Create Trigger with txt install.sql


Recommended Posts

Hi,

I want when i install my new module install tale in DB with Trigger.

For the moment, i only table creaed, but i have erreur in trriger creation

Note: My DB is phpmyadmin

CREATE TABLE IF NOT EXISTS `PREFIX_catg` (
  `id_catg` int(11) NOT NULL AUTO_INCREMENT,
  `myid` VARCHAR( 255 ) NOT NULL,
  `id_category` int(11) NOT NULL,
  PRIMARY KEY (`id_catg`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `PREFIX_newcategory` (
  `id` int(11) NOT NULL,
  `categoryid` varchar(255) CHARACTER SET utf8 NOT NULL,
  `idauto` int(11) NOT NULL,
  `idautomatomte` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`idautomatomte`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
CREATE TRIGGER `UPwave` AFTER UPDATE ON `PREFIX_catg`
 FOR EACH ROW UPDATE `PREFIX_newcategory`
SET `PREFIX_newcategory`.id = new.id_category , `PREFIX_newcategory`.categoryid = new.myid
WHERE `PREFIX_newcategory`.idauto = old.id_catg
CREATE TRIGGER `DELETEwave` AFTER DELETE ON `PREFIX_catg`
 FOR EACH ROW DELETE FROM `PREFIX_newcategory`
WHERE `PREFIX_newcategory`.idauto = old.id_catg
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...