Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Sample events > Database

PHPrunner32x32     PHPRunner manual


Update multiple tables

Scroll Prev Next More

 

To update two joined tables, use the following code in the Add page: Before record added and/or Edit page: Before record updated events.

 

Note: Change red values to match your project.

 

$sql = "update othertable set joinedfield=".$values["joinedfield"]." ... ";
db_exec($sql);
unset($values["joinedfield"]);

 

To update master and details tables, use the following code for the details table in the Add page: Before record added and/or Edit page: Before record updated events:

 

global $dal;
$tblDetail = $dal->Table("DetailTableName");
$tblDetail->Value["Field1"] = $values["Field1"];
$tblDetail->Param["OrderID"] = $values["OrderID"];
$tblDetail->Update();
unset($values["Field1"]);

 

"Field1" is a field in the details table and "OrderID" is the linked field in the master table.

See also:

Data Access Layer

Database API

Database API: DB::Exec

Master-details relationship between tables

Update multiple records on the List page

 

Created with Help+Manual 7 and styled with Premium Pack Version 3 © by EC Software