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.

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

报告相同问题?

悬赏问题

  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了