Page 1 of 1

Update Another Table's DateTime Field

Posted: 2018-08-13 13:08
by yonder
Hi there,

I have 2 tables; "Projects" and "Projects_Details".

First table's fields;
- id
- project_no
-project_name
- last_update_datetime

Second table's fields;
- id
- project_no (it's lookup field that get data from first table)

When i add a new record to the second table, i want to add automatically date and time to the first table's "last_update_datetime" field (i mean i want to do that with "before update" or "after update" hook).

How can i do that?

Best Regards.

Re: Update Another Table's DateTime Field

Posted: 2018-08-13 14:50
by pbottcher
Hi,

you can just add in the Projects_Details_after_update function:

Code: Select all

sqlvalue("update Projects set last_update_datetime=now() where id = ".$data['project_no']);