This topic is locked

UPDATE FIELD

6/9/2014 5:11:50 AM
PHPRunner General questions
A
alina author

Hi, can you help me for PHPRunner?
I have this tables:

  1. TABLE called MENUMASTER with this fields: IDmenu, datamenu (date) ...> master
  2. TABLE called MENUDETAILS with this fields: ID, menu, piatto ...> detail
  3. TABLE called PIATTO with this fields: IDpiatto, piatto, datamenu (date)
    Problem:
    How can I do to update datemenu in table called "PIATTO" with datamenu in table called MENUMASTER when

    I add a record in TABLE called MENUDETAILS

    I modify a record in TABLE called MENUDETAILS

    I delete a record in TABLE called MENUDETAILS
    Thank you

Sergey Kornilov admin 6/10/2014

You can add events like AfterAdd, AfterEdit and BeforeDelete to MENUDETAILS table.
Here is the sample code for AfterEdit event:



$rs = CustomQuery("select datamenu from MENUMASTER where IDmenu=".$values["menu"]);

if ($data = db_fetch_array($rs)) {

CustomQuery("update PIATTO set datamenu=".$data["datamenu"]." where IDpiatto=".$values["piatto"]);

}