<?php
class ModelCatalogaviseme extends Model {
    
	public function install() {

        $this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "product_email_letme` (
        
		   `letme_id` integer not null AUTO_INCREMENT primary key,
           `product_idfutura` integer not null,
		   `name` varchar(50),
		   `email` varchar(200),
		   `link_produto` varchar(200),
		   `id_futura` integer
		
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
	  

	    $this->db->query("CREATE TRIGGER  product_email_letme_AI
						 AFTER INSERT on ". DB_PREFIX ."product_email_letme
						 FOR EACH ROW
						 begin
						   call SP_SET_CHANGE_EFUTURA('".DB_PREFIX ."product_email_letme','letme_id',NEW.letme_id,'I', null);
						 end");  
	    
		$this->db->query("CREATE TRIGGER  product_email_letme_AU
						  AFTER UPDATE on ". DB_PREFIX ."product_email_letme
						  FOR EACH ROW
						  begin
							call SP_SET_CHANGE_EFUTURA('".DB_PREFIX ."product_email_letme','letme_id',NEW.letme_id,'U', null);
						end");
        
		$this->db->query("CREATE TRIGGER product_email_letme_AD
						  AFTER DELETE on ". DB_PREFIX ."product_email_letme
                          FOR EACH ROW
						  begin
                            call SP_SET_CHANGE_EFUTURA('".DB_PREFIX ."product_email_letme','letme_id',OLD.letme_id,'D', OLD.ID_FUTURA);
						  end");
	}

    public function uninstall() {

        $this->db->query('DROP TABLE IF EXISTS `' . DB_PREFIX . 'product_email_letme`');
		$this->db->query('DROP TRIGGER IF EXISTS product_email_letme_AI');
		$this->db->query('DROP TRIGGER IF EXISTS product_email_letme_AU');
		$this->db->query('DROP TRIGGER IF EXISTS product_email_letme_AD');
    }
		
}
?>




 



  








 