This topic is locked

Copy Record into New Table using Button

9/20/2013 5:01:14 PM
PHPRunner General questions
D
dustinforehand author

Good Afternoon Everyone.

I was looking for help on how to copy record data from one table to another. The following example worked great in the events section, but I could not get it to work under a button. Can anyone help me apply this to a button.
//** Save old/new data record in another table ****

global $dal;

$tblUsers = $dal->Table("YOURNEWTABLE");

$tblUsers->Param["ID"]=$values["ID"];//optional for where

$tblUsers->Value["Field1"]=$values["Field1"];

$tblUsers->Value["Field2"]=$values["Field2"];

$tblUsers->Value["Field3"]=$values["Field3"];

$tblUsers->Add();
return true;
// second table should be auto number and this field should not be included above.

Also useful for archive backup recovery....

C
cgphp 9/22/2013

In the "Server" section of the button, you have to fetch the records of the source table you want to backup.

  1. Fetch the records from the source table
  2. Loop through the fetched records
  3. Insert/Update the records to the target table