douwan2664 2015-04-13 12:56
浏览 42
已采纳

如何使用表字段id在phpMyAdmin中为MySQL事件提供外键

Well I am using MySQL Event and it generated when record inserted in table..... I don't know how to give foreign key to MySQL event with table record

$schedule = $this->db->query("CREATE EVENT ".$data['id']." ON SCHEDULE 
EVERY 1 MONTH ON COMPLETION PRESERVE ENABLE DO INSERT INTO oops_invoice 
(id, prefix, number, bill, account_id, order_delivery_id, date, staff_id, 
customer_note, recurrence, status, itp, utp) VALUES ('', '".$data['prefix']."',
 '".$data['number']."', '".$data['bill']."', '".$data['account_id']."', NULL,
 '".$data['date']."', NULL,'".$data['customer_note']."', '".$data['recurrence']."',
 'Draft', '".$data['itp']."', CURRENT_TIMESTAMP)");

$this->db->query("SET GLOBAL event_scheduler =  'ON'");

PROBLEM:

My problem is that when entry of the table is deleted at that time it's appropriate MySQL Event should be deleted....

It means something like foreign key to MySQL event please someone help me....

  • 写回答

1条回答 默认 最新

  • doucaishou0074 2015-04-25 12:55
    关注

    I think you are asking is not possible but instead of that you can use trigger...

    which will help you that when you row in table is deleted from phpmyadmin at that time according to trigger and row id you can delete your MySQL event.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计
  • ¥20 用keil,写代码解决两个问题,用库函数
  • ¥50 ID中开关量采样信号通道、以及程序流程的设计
  • ¥15 U-Mamba/nnunetv2固定随机数种子
  • ¥15 vba使用jmail发送邮件正文里面怎么加图片
  • ¥15 vb6.0如何向数据库中添加自动生成的字段数据。