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.

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

报告相同问题?