Update parent table field from child table.

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
zkarwinkar
Veteran Member
Posts: 32
Joined: 2021-06-12 21:01

Update parent table field from child table.

Post by zkarwinkar » 2022-04-16 10:29

Hi,
i have parent table items as ,

1) id
2) item_name
3) current_location (readonly)

child table as location transfer as,

1) id
2) item_id
3) new_location

i need to update current_location from child table as per last entry of new_location field .
please help . thanks

xbox2007
Veteran Member
Posts: 136
Joined: 2016-12-16 16:49

Re: Update parent table field from child table.

Post by xbox2007 » 2022-04-16 10:42

Code: Select all

function location_after_insert($data, $memberInfo, &$args) {
		$item = $data['item_id'];
		$location   = $data['new_location'];	
                
                sql("update items  set current_location  = '{$location}'  where  id ='{$$item}' ", $eo);	
	
		return TRUE;
	}


zkarwinkar
Veteran Member
Posts: 32
Joined: 2021-06-12 21:01

Re: Update parent table field from child table.

Post by zkarwinkar » 2022-04-16 11:11

thank you sir !!!

Post Reply