Skip to main content

How to update two (2) joint tables:

  • First table name as “project_sti” with fields [id_project] as primary key and field “[sti_org] that link with field [id_sti_org] in table “sti_org“.
  • Second table name as “sti_org” with fields [id_sti_org] as primary key and field [ssm_no] that you want to update/key-in data.

Example:

Table: project_sti

id_project (primary_key)
— name
sti_org

Table: sti_org

id_sti_org (primary_key)
ssm_no

Solution / Recommendation

Location Event:

  • Tab > Table Name project_sti > Add page > Before record added
  • Tab > Table Name project_sti > Edit page > Before record upated

Add the following code:

// Array data list
$fieldValues = array();
$keyValues = array();

// Update the field in sti_org
// ssm_no is the field that you want to update/key-in data
$fieldValues[“ssm_no“] = $values[“ssm_no“];

// Linked field in project_sti
// id_sti_org is from table sti_org
// sti_org is from table project_sti

$keyValues[“id_sti_org“] = $values[“sti_org“];
DB::Update(“sti_org“, $fieldValues, $keyValues);

// field from sti_org that appear on project_sti edit page
unset($values[“ssm_no“]);

//settle
return true;