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.

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

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效